我有一个问题,这已经在工作了,我想让它在访问中的数据库之间进行比较
I have a question, this is alredy working and want's to make this to do a comparative betwen an db in acccess
经过一些更改后,我得到了这个,但仍然有关于这是否会将数据从不同的 table 发送到另一个不同的 table 的问题。笔记
这已经在工作了,并且做得很好 deon be hestiating and a bully this works.
USE [ComercialSP] -------------- you need to inititate your db were will be this
GO
/****** Object: Trigger [dbo].[addNewProduct] Script Date: 12/16/2021 12:26:07 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE TRIGGER [dbo].[ADDallProduct] ON [dbo].[orgProduct] -----first you need to create into a table in a DB
AFTER INSERT --this is only for an 'after insert'
AS
DECLARE -------- declaration of var's
@Component NVARCHAR(40),
@Component2 NVARCHAR(150),
@Component3 NVARCHAR(150),
@CompaqiID BIGINT,
@Desc NVARCHAR(50),
@Dept NVARCHAR(15),
@Cata NVARCHAR(50),
@Cost INT = 234
BEGIN -------- end of a dec
SET NOCOUNT ON
SELECT @Component = inserted.ProductName FROM INSERTED WHERE Category1 = 'Tela' and Category2 <> 'Yarns' ---- for a component we need a condition who will separate thhe thinks we need and in what DB is be inserted
SELECT @Component2 = inserted.ProductName FROM INSERTED WHERE Category1 = 'Tela' and Category2 = 'Yarns' or Category1 <> 'Tela' ---- this to
SELECT @Dept = inserted.Category1 FROM INSERTED --------- and we need to make some var's habiable for insert in te kye's for the db in this case @Dept, @cata, @CompiaquiID, and also @component, and @Component2
SELECT @Cata = inserted.Category2 FROM INSERTED
SELECT @CompaqiID = inserted.ProductID FROM INSERTED
IF (@Component IS NOT NULL ) -----------we need a condition IF for this cause we want mistakes on code
BEGIN
INSERT INTO Quality_be.dbo.[FabComponents t] -------- inseertion in what db we want
(Component,[Desc],Cata,CompaqiID) --------the fields name of the db
VALUES
(@Component,@Desc,@Cata,@CompaqiID) ------ and what var's we need insert
END -------- the end of this IF
ELSE -------------- a ELSE for the other condition
BEGIN ------------ the BEGIN for initiate other condition
INSERT INTO Purchasing_be.dbo.[FabComponents t] -----------where you will insert this
(Component,[Desc],Cata,Dept,CompaqiID,CostAcc) ------------- the var's we'il need for this field's into this db
VALUES
(@Component2,@Desc,@Cata,@Dept,@CompaqiID,@Cost) --------------- and what var's we will need for this db
END ---------------end of this condition
END
----------------- end of this trigger
所以这个结束了,这已经是我唯一想要的工作了,在插入之前对一个名为 Quality_be 的数据库进行比较,并且它被绑定到访问
如果您使用 sql 服务器触发器语法如下:
CREATE TRIGGER [ NoYarnsH ] ON Purchasing_be.dbo.orgProduct
AFTER INSERT
AS
BEGIN
INSERT INTO Quiality_be.dbo.FabComponents_t
SELECT *
FROM INSERTED
WHERE YOUR_COLUMN IN ('Tela', 'Yarns')
END
经过一些更改后,我得到了这个,但仍然有关于这是否会将数据从不同的 table 发送到另一个不同的 table 的问题。笔记 这已经在工作了,并且做得很好 deon be hestiating and a bully this works.
USE [ComercialSP] -------------- you need to inititate your db were will be this
GO
/****** Object: Trigger [dbo].[addNewProduct] Script Date: 12/16/2021 12:26:07 AM ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
CREATE TRIGGER [dbo].[ADDallProduct] ON [dbo].[orgProduct] -----first you need to create into a table in a DB
AFTER INSERT --this is only for an 'after insert'
AS
DECLARE -------- declaration of var's
@Component NVARCHAR(40),
@Component2 NVARCHAR(150),
@Component3 NVARCHAR(150),
@CompaqiID BIGINT,
@Desc NVARCHAR(50),
@Dept NVARCHAR(15),
@Cata NVARCHAR(50),
@Cost INT = 234
BEGIN -------- end of a dec
SET NOCOUNT ON
SELECT @Component = inserted.ProductName FROM INSERTED WHERE Category1 = 'Tela' and Category2 <> 'Yarns' ---- for a component we need a condition who will separate thhe thinks we need and in what DB is be inserted
SELECT @Component2 = inserted.ProductName FROM INSERTED WHERE Category1 = 'Tela' and Category2 = 'Yarns' or Category1 <> 'Tela' ---- this to
SELECT @Dept = inserted.Category1 FROM INSERTED --------- and we need to make some var's habiable for insert in te kye's for the db in this case @Dept, @cata, @CompiaquiID, and also @component, and @Component2
SELECT @Cata = inserted.Category2 FROM INSERTED
SELECT @CompaqiID = inserted.ProductID FROM INSERTED
IF (@Component IS NOT NULL ) -----------we need a condition IF for this cause we want mistakes on code
BEGIN
INSERT INTO Quality_be.dbo.[FabComponents t] -------- inseertion in what db we want
(Component,[Desc],Cata,CompaqiID) --------the fields name of the db
VALUES
(@Component,@Desc,@Cata,@CompaqiID) ------ and what var's we need insert
END -------- the end of this IF
ELSE -------------- a ELSE for the other condition
BEGIN ------------ the BEGIN for initiate other condition
INSERT INTO Purchasing_be.dbo.[FabComponents t] -----------where you will insert this
(Component,[Desc],Cata,Dept,CompaqiID,CostAcc) ------------- the var's we'il need for this field's into this db
VALUES
(@Component2,@Desc,@Cata,@Dept,@CompaqiID,@Cost) --------------- and what var's we will need for this db
END ---------------end of this condition
END
----------------- end of this trigger
所以这个结束了,这已经是我唯一想要的工作了,在插入之前对一个名为 Quality_be 的数据库进行比较,并且它被绑定到访问
如果您使用 sql 服务器触发器语法如下:
CREATE TRIGGER [ NoYarnsH ] ON Purchasing_be.dbo.orgProduct
AFTER INSERT
AS
BEGIN
INSERT INTO Quiality_be.dbo.FabComponents_t
SELECT *
FROM INSERTED
WHERE YOUR_COLUMN IN ('Tela', 'Yarns')
END