I am trying to create a SQL Server 2008R2 Table column with automatically calculated current datetime for every row I insert.
I set Computed Column Specification value for this column equals to GetDate(). My table had some old data in it. After adding GetDate() function, the column get updated with current datetime. But my problem is, When i insert new row in this table, my datetime column never get updated with current date time and this column have same value for each row.
Which function should I use to insert current datetime value for column when I insert a new record?
Try setting GETDATE()
to be the DEFAULT
value for the column.
You can set the column's default value with the GETDATE
(), with this you will get the current DateTime on every new row insert.
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