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)
 trigger syntax

Author  Topic 

tcv56
Starting Member

12 Posts

Posted - 2007-01-28 : 23:17:29
Hi all,

How do I code a trigger (sql 2000) that will copy some data from some existing tables (in the same dbA) to another databaseB only when a column (from dbA) meet a certain condition.

DB1: dbA
Table1: name, age, race
Table2: race, degree, interests, lifestyle, career

DB2: dbB
Table1: race, age, interests

If age is 50 copy race, age & interests from DB1 to DB2

Thanks

chiragkhabaria
Master Smack Fu Yak Hacker

1907 Posts

Posted - 2007-01-29 : 00:43:20
Somthing like this

Create Trigger dbo.InsdbBTableA
On Table1
For Insert
As
Begin
Insert dbB..Table1
(
Race,
Age,
Interests
)
Select t1.Race,
t1.Age,
t2.Interests
From Inserted t1 Inner Join Table2 t2
On t1.Race = t2.Race
Where
t1.Age = 50
End


Chirag

http://chirikworld.blogspot.com/
Go to Top of Page

tcv56
Starting Member

12 Posts

Posted - 2007-01-29 : 12:00:50
I will give it a try . Thanks
Go to Top of Page
   

- Advertisement -