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
 General SQL Server Forums
 New to SQL Server Programming
 sql trigger

Author  Topic 

Anand.A
Posting Yak Master

109 Posts

Posted - 2011-12-29 : 01:56:04
hi
i am having table like this

stu_id stu_name stu_cla created_Datetime
1 AA A
2 BB B
3 CC A

here i want to create a trigger to genrate created_Datetime as getdate()
how to write a trigger for this

anand

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-12-29 : 02:04:54
you don't really need trigger.

You can use a DEFAULT CONSTRAINT, like

create table student
(
stuid int,
stu_name varchar(100),
. .. .
created_datetime datetime default getdate()
)
insert into student (stuid, stu_name)
values (1, 'AA')




KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page
   

- Advertisement -