Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 creating a trigger

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-12-11 : 07:56:54
ROLLY writes "I am new to SQL programming. MSSQL server 7.0

I need to create a trigger for insert from one database to another. on a linked server.
Here is something I am trying to do can you help?
desperate. Can you help??

I want a trigger on a table called DAILYTRANS
I need to insert from this query

SELECT a.CAdvances, a.ScliNum, a.SCoNum, a.sLoanNum, b.sRepNum
From Dailytrans a, dda b
where a.ScliNum = b.ScliNum
AND a.SCoNum = b.SCoNum
AND a.sLoanNum = b.sLoanNum
AND a.sCollectNum = "ADVRQS"

FOR INSERT into a table called CASHINT
that sits on a diifrent server and database

Below is what I was trying to do.

CREATE TRIGGER TrgInsertAdvanceWires
ON DailyTrans
FOR INSERT
AS
BEGIN
IF (SELECT count(1) FROM INSERTED) = 1
BEGIN
INSERT INTO [la-XRT].XRT.dbo.CASHINT(ins. SHELL_ID , TRANS_AMOUNT , TIME_STAMP)
SELECT a.CAdvances, a.ScliNum, a.SCoNum, a.sLoanNum, b.sRepNum
From Dailytrans a, dda b
where a.ScliNum = b.ScliNum
AND a.SCoNum = b.SCoNum
AND a.sLoanNum = b.sLoanNum
AND a.sCollectNum = "ADVRQS"

IF @@ERROR <> 0
BEGIN
ROLLBACK TRANSACTION
RAISERROR(65001, 11, 1, "TrgInsertAdvanceWires", "Error on inserting AdvanceWires!")
END
END
"

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-12-11 : 12:29:58
So what isn't your trigger currently doing? Do you get an error?

Tara
Go to Top of Page
   

- Advertisement -