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
 How to capture system date ?

Author  Topic 

NijelJ22
Starting Member

18 Posts

Posted - 2008-08-23 : 03:18:51
1) I have to write a query. I have a field name called "Flag" which is used only to track the status and hence stores "0" and "1". I want to capture the system date when user enter "1" in this field.Is it possible if yes then how?

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-08-23 : 04:19:58
select getdate() as date
Go to Top of Page

NijelJ22
Starting Member

18 Posts

Posted - 2008-08-23 : 04:36:10
Hi Africa,

Thanks for your help.

I know how to capture the system date, that was not my question.
My question was:

I have a table that contains "Flag" as a field. That tables conatins several records. Now i want to write a query that returns me tha date when that flag was updated from 0 to 1.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2008-08-23 : 04:39:59
use a update trigger

update t
set somedatecol = getdate()
from yourtable t
inner join deleted d on t.pkcol = d.pkcol
inner join inserted i on t.pkcol = i.pkcol
where d.Flag = 0
and i.Flag = 1



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

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-23 : 07:15:37
quote:
Originally posted by NijelJ22

Hi Africa,

Thanks for your help.

I know how to capture the system date, that was not my question.
My question was:

I have a table that contains "Flag" as a field. That tables conatins several records. Now i want to write a query that returns me tha date when that flag was updated from 0 to 1.


do you capture the audit info of this table somewhere? May be a history or audit table?
Go to Top of Page
   

- Advertisement -