am using SQL server 2005 , i have a requirement to get the Creation datetime of all the rows in a particular table, unfortunately the table do not have any "rowverion" or datetime column ( i know this is a major design flaw).
so , i was wondering if SQL server maintains datetime for each row inserts.
comments suggestions appreciated
Regards Deepak
No, SQL Server does not timestamp the rows automatically when they are created. As you suggested, for the future, you may want to create a new date_created column and set it default to GETDATE():
ALTER TABLE your_table
ADD CONSTRAINT dc_your_table_date_created
DEFAULT GETDATE()
FOR date_created;
You may also use a trigger instead, if you prefer, as @Vash suggested in the other answer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With