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
 Transact-SQL (2000)
 new to trigger

Author  Topic 

ForceF16
Starting Member

13 Posts

Posted - 2007-02-28 : 13:35:00
Hi,

I have two tables in one database. I need to create a trigger in order to sync both tables.

Table 1 Table 2

Column Name: Column Name:

User_Name FirstName
User_email MidleName
State LastName
Email
State
User_Title Title
User_Phone Phone

Here is my question: IF I need to update info on table 1 and it's automatically update on table 2. can someone can help me to write a trigger like this? Thanks, Dan


dan

spirit1
Cybernetic Yak Master

11752 Posts

Posted - 2007-02-28 : 13:41:40
create trigger trigTable1 on table1 for update, insert
as
insert into table2 (yourColumns)
select yourColumns
from inserted

Causing trouble since 1980
blog: http://weblogs.sqlteam.com/mladenp
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2007-02-28 : 13:43:38
Triggers are usually bad to use. So please explain why you want to update Table2 when Table1 gets updated. What is the business requirement here?

Tara Kizer
Go to Top of Page

ForceF16
Starting Member

13 Posts

Posted - 2007-02-28 : 14:38:06
Tara,

it's a requiremnent in this enviromnent. what are the other options need to be done other than Trigger? Please let me know.

Dan


dan
Go to Top of Page
   

- Advertisement -