Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Null Foreign Keys
Message
 
To
03/08/2015 03:57:04
General information
Forum:
Microsoft SQL Server
Category:
Database design
Environment versions
SQL Server:
SQL Server 2012
Application:
Desktop
Miscellaneous
Thread ID:
01622856
Message ID:
01622896
Views:
41
>>>>This is a bit non-traditional and complex relation.
>>>
>>>Thanks. I'll think about how to simplify it.
>>>
>>>Also, are you sure you want to have LastUpdatedDate to be getdate() and not CreatedDate. Logically I'd think the first date should be updated every time a row is updated and the first date should be populated once when row is created.
>>>
>>>That's exactly what I thought I was doing, am I not? Am misunderstanding how default works. I was hoping that on update the lastupdatedate field would be automatically updated if I set up things in this way.
>>
>>Setting a default will only set a value on an INSERT, not on an UPDATE.
>>
>>In order to set the LastUpdate date on an UPDATE statement, you'll either need for the application or stored procedure (if you're using them) to set it on an UPDATE....or (as some people will do) you can build an UPDATE trigger that will set the lastupdate date.
>
>I would have guessed your ordered preferences to be SP, trigger, application, but interpret the above otherwise? No worry about clock differences between client machines?

Right! Point well taken. Although my environment is desktop.

If things have the tendency to go your way, do not worry. It won't last. Jules Renard.
Previous
Reply
Map
View

Click here to load this message in the networking platform