Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

insert trigger

Status
Not open for further replies.

TechJatt

Programmer
Jul 16, 2003
6
US
I want to make a trigger that automatically sets the date of a field when being inserted. So the trigger goes through and does something like: set tdate = getdate()

i cant get it to work through. when i try set inserted.tdate = getdate(), it wont let me. i know that oracle has a 'for each row' argument you can add to make it apply to each row being inserted, but cannot find a similar command for t-sql.

any suggestions>
 
Yes yes....try to create defult instead of using trigger

create default time_default as getdate()

sp_bindefault time_default,'mytable.col1'

say your table called Mytable with col1 , col2 and col3

after binding default ,your insert statement will be

insert into MyTable(col2,col3) select 'haha','wawa'



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top