Click here to Skip to main content
15,909,498 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Could some one please help me as i got a task which is as follows:

Suppose i am having a table test with columns and data :

C#
ID   Name   Address  Create_date  Update_date
1    abc    india    2013-08-11    NULL
2    xyz    india    2013-08-11    NULL

Now if you see in the above data the update_date is NULL . Now I want that if we update the record at that time it should give me the update_date. For this approach i dnt want to use any Trigger.

For example:

If i updated row for Id=1 then the data should be like this..

C#
ID   Name   Address  Create_date  Update_date
1    abc    US       2013-08-11   2013-08-22 


Thanks,
Preetpal Kapoor
Posted
Updated 22-Aug-13 21:18pm
v2

Hi, You could use GETDATE() function.

E.g.
SQL
UPDATE Table_Name
SET Update_Date = CONVERT(char(10), GETDATE(),126)
WHERE ID = 1
 
Share this answer
 
v3
A defaul constraint only works on inserts, for an update use a trigger

If you don't want to use triggger i think that is not impossible to solve this issue.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900