This is my trigger, it work on a DB named dbo.orgProduct
in a DB called Purchasing_be
but i want to discriminate some words like Yarns, and Hilo, if these words are put in the table of this database I want to send to another database called Quiality_be
in dbo.FabComponents_t
. This is my code.
CREATE TRIGGER [ NoYarnsH ]
ON dbo.orgProduct
DECLARE
@VAR1 NVARCHAR(MAX),
@VAR2 NVARCHAR(MAX),
@PRONA NVARCHAR(MAX),
@CATE1 NVARCHAR(MAX),
@CATE2 NVARCHAR(MAX),
@CATE1== OrgProduct.category1,
@CATE2== OrgProduct.category2,
@PRONA== OrgProduct.ProductName,
AFTER INSERT
IF (@var1 =="Tela") && (@Var 2 =!"Yarns") Begin
INSERT into @PRONA.[Quality_be].@Component
INSERT into @CATE1.[Quality_be].@Desc
INSERT into @CATE2.[Quality_be].@Cata
AS
SET NOCOUNT ON;
EXECUTE AS Clause
END
GO
CodePudding user response:
If your using sql server trigger syntax would be like this :
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
CodePudding user response:
@Dourayd TLILI So if someone puts a new income this will be in the other DB?
CREATE TRIGGER [ NoYarnsH ] ON ComercialISP.dbo.orgProduct
AFTER INSERT
AS
BEGIN
INSERT INTO Quiality_be.dbo.FabComponents_t
SELECT *
FROM INSERTED
WHERE Category1 IN ('Tela') & Category2 IN ('Yarns')
END
o this will take all of the resulsts?, im ask because the DB has more of these and i only whants to send te new ones, not all.