Information générale
Forum:
Microsoft SQL Server
Catégorie:
Conception bases de données
Versions des environnements
SQL Server:
SQL Server 2012
>>>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?
Précédent
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement