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 |
|
naumangee
Starting Member
2 Posts |
Posted - 2008-05-08 : 11:06:29
|
| Hi, I have a table with somefields, here i will only mention on which i need to perform an action, possibly with the use of Trigger. Fields = Active, inactiveDateActive Field is of bit datatype mean conatins 1 or 0, 1 means the user is active, but when i change the active field to 0, and make the user inactive i want the date to be populated automatically to inactiveDate field when active field is changed to 0.any help is much appreciatedNAUMAN |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-05-08 : 11:26:51
|
| [code]CREATE TRIGGER YourTrigger ON YourTableAFTER UPDATEASBEGINUPDATE tSET t.InactiveDate=GETDATE()FROM YourTable tINNER JOIN INSERTED iON i.PKCol=t.PKColWHERE i.Active=1END[/code] |
 |
|
|
naumangee
Starting Member
2 Posts |
Posted - 2008-05-08 : 11:45:46
|
| Thank you so much Visakh. It's perfect.NAUMAN |
 |
|
|
|
|
|