May 19, 2010

Set a field of table to do auto entry as the current date when Inserting a new record in Micrososft SQL Server 2005

There are 2 simple ways to do it:

Method 1:
Complete the following steps and you are done:
  1. Right click on the name of table
  2. select design
  3. click on field where you want to create auto entry of current date
  4. now look in the “Column Properties” window
  5. Under the General group there is property called “Default value or Bindind”
  6. in that type in “(getdate())” and save.
Method 2:
You can use getdate() function in the insert query too.

No comments:

Post a Comment