Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
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: dbATable1: name, age, raceTable2: race, degree, interests, lifestyle, careerDB2: dbBTable1: race, age, interestsIf age is 50 copy race, age & interests from DB1 to DB2Thanks
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts
Posted - 2007-01-29 : 00:43:20
Somthing like this
Create Trigger dbo.InsdbBTableAOn Table1For 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