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.
| Author |
Topic |
|
asifbhura
Posting Yak Master
165 Posts |
Posted - 2011-08-01 : 12:38:34
|
| Hello Sir,I created trigger as belowALTER TRIGGER SetCreation_date ON dbo.Content_Header after updateAS update dbo.Content_Header set CreationDate=getdate()GOit updates all records, i want to be set getdate() on only updated records,So,I tried like belowALTER TRIGGER SetCreation_date ON dbo.Content_Header after updateAS update dbo.Content_Header set CreationDate=getdate() FROM UPDATEDGObut doesnt work...How can i set getdate on only updated recordRegards, |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-01 : 12:47:00
|
you should be using inserted or deleted tables for thisALTER TRIGGER SetCreation_date ON dbo.Content_Headerafter updateAS update c set c.CreationDate=getdate() FROM dbo.Content_Header cINNER JOIN INSERTED iON i.OK= c.PKGO PK is your primary key column------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
asifbhura
Posting Yak Master
165 Posts |
Posted - 2011-08-01 : 17:03:31
|
| thanx |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-02 : 01:02:01
|
| welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|