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 2005 Forums
 Transact-SQL (2005)
 Trigger help

Author  Topic 

fralo
Posting Yak Master

161 Posts

Posted - 2010-12-07 : 16:24:35
Hi,

I desperately need help with creating a database trigger. I need to insert into a second table after a first table is inserted into. I thought a trigger is what I needed.

I think it's something like this...

CREATE TRIGGER employee_data on table/database(?)
after update
as

insert into employee
(name, ssn)
values (@name, @ssn)
go

In this case, @name and @ssn would be fields that were inserted into the first table here. How could I capture these values and would I need to DECLARE them?

Thanks for your help.

pk_bohra
Master Smack Fu Yak Hacker

1182 Posts

Posted - 2010-12-07 : 22:44:58
if name and ssn columns are there in employee_data table then they can be accessed from Inserted table.

For more information on Inserted table, refer the link:
http://msdn.microsoft.com/en-us/library/aa214435(SQL.80).aspx
Go to Top of Page
   

- Advertisement -