It is very common requirement while development that in SQL Server we have to insert current date and time on particular column like Record Created Date.
To fullfill this kind of requirement, there is a provision in SQL Server i.e. Default Value or Binding property, if we use this property then we dont need to provide date time value explicitly while inserting the record.
This can also be done through the SSMS GUI.
- Put your table in design view (Right click on table in object explorer->Design)
- Add a column to the table (or click on the column you want to update if it already exists)
- In Column Properties, enter
(getdate())
in Default Value or Binding field as pictured below
No comments:
Post a Comment