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 |
|
4colors
Starting Member
2 Posts |
Posted - 2009-04-07 : 15:24:25
|
| Is there any way to show all modified or added records in a table based on a field that has timestamp as a datatype?for exampleselect ID, Name, DOB, mytimestampfrom employeewhere mytimestamp (Changed/added)in the previous example i would like to show all employee information wherever timestamp field changes or modifiedMany thanx-----------------------Smile |
|
|
SwePeso
Patron Saint of Lost Yaks
30421 Posts |
Posted - 2009-04-07 : 15:27:38
|
Modified or changed since when? E 12°55'05.63"N 56°04'39.26" |
 |
|
|
4colors
Starting Member
2 Posts |
Posted - 2009-04-07 : 23:18:59
|
quote: Originally posted by Peso Modified or changed since when?
I want to keep getting all records that changed at anytime (i mean whenever mytimestamp changes)*i depended on timestamp becoz i couldn't think of another idea. if you have better idea please let me know& many many Thanx-----------------------Smile |
 |
|
|
asgast
Posting Yak Master
149 Posts |
Posted - 2009-04-08 : 04:13:31
|
| i think you want two different things combined in oneyou can have an after update trigger to time stamp data change, then if you select mytimestamp is not null you'll get data that was modified in the table.examplecreate TRIGGER yourtriger ON yourtableAFTER UPDATEASSET NOCOUNT ONUPDATE dbo.yourtable SET mytimestamp =GETDATE()FROM yourtable yINNER JOIN inserted i ON i.ID=y.IDthis will change mytimestamp everytime a row is updated |
 |
|
|
|
|
|