This is the first trigger I've ever created, so bear with me....
First off, I created a linked server called "LDOS" .
In the parent server that hosts the server link, I am trying to create an inserted record trigger that will insert values from the inserted record, into a table located on this linked server called "tblProjectNumber". So far, I have this:
CREATE TRIGGER ProjectNoTrigger
ON dbo.tblArHistHeader
FOR INSERT
/* INSERT, UPDATE, DELETE
*/
AS
DECLARE @TransId VARCHAR(8)
DECLARE @CustId VARCHAR(10)
BEGIN
SELECT @TransId =(SELECT TransId FROM INSERTED);
END
BEGIN
SELECT @CustId =(SELECT CustId FROM INSERTED);
END
OPENQUERY (LDOS,"INSERT INTO LDOS.tblProjectnumbers (TransID, CustId)
VALUES(@TransId,@CustId)"
GO
It errors out on the OPENQUERY line with an error "Incorrect syntax near OPENQUERY"
Any help is appreciated!
Thanks!
First off, I created a linked server called "LDOS" .
In the parent server that hosts the server link, I am trying to create an inserted record trigger that will insert values from the inserted record, into a table located on this linked server called "tblProjectNumber". So far, I have this:
CREATE TRIGGER ProjectNoTrigger
ON dbo.tblArHistHeader
FOR INSERT
/* INSERT, UPDATE, DELETE
*/
AS
DECLARE @TransId VARCHAR(8)
DECLARE @CustId VARCHAR(10)
BEGIN
SELECT @TransId =(SELECT TransId FROM INSERTED);
END
BEGIN
SELECT @CustId =(SELECT CustId FROM INSERTED);
END
OPENQUERY (LDOS,"INSERT INTO LDOS.tblProjectnumbers (TransID, CustId)
VALUES(@TransId,@CustId)"
GO
It errors out on the OPENQUERY line with an error "Incorrect syntax near OPENQUERY"
Any help is appreciated!
Thanks!