none
Current date as default value in SQL Server table

    Question

  • In MS Access you can simply type "Now()" as the default attribute of a date field, and every new record gets the current date automatically. Is there a similar way to do this in SQL Server, please? Nothing I've tried so far works.

    Thursday, August 23, 2007 12:17 PM

Answers

All replies

  • The following ones are possible:

    SELECT CURRENT_TIMESTAMP
    SELECT {fn NOW()}
    SELECT GETDATE()
    Thursday, August 23, 2007 4:38 PM
  • Hello bhssc,

     

     

    Yes in SQL server 2000/2005 you can set the default value for the row.

    just write "getdate()" for the default value of a row and it will insert the current date and time when a new row is inserted.

     

     

    • Proposed as answer by Dibley1973 Tuesday, September 13, 2011 6:03 AM
    Wednesday, September 12, 2007 7:17 AM
  • Thank you UmeshForyou,

    Using "getDate()" in the default column value worked fine for me. +1


    • Edited by Dibley1973 Tuesday, September 13, 2011 6:04 AM
    Tuesday, September 13, 2011 6:02 AM