Take the 2-minute tour ×
Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. It's 100% free, no registration required.

I need a timestamp to be created automatically when I insert information in a table. mySQL has TimeStamp but MS SQL Server TimeStamp doesn’t correspond mySQL. Is there any other way around?

share|improve this question
add comment

1 Answer 1

up vote 4 down vote accepted

From MSDN: "The Transact-SQL timestamp data type is not the same as the timestamp data type defined in the SQL-92 standard. The SQL-92 timestamp data type is equivalent to the Transact-SQL datetime data type."

To be able to have a date automatically inserted in your table, you should have a column of type datetime with a default value of getdate() - the system function that shows the current date of the system.

share|improve this answer
    
Thank you for pointing me to right direction! –  Amir Rezaei Jan 26 '11 at 8:06
2  
To build on that, if you are using SQL Server 2008 or higher you'll want to use the new SYSDATETIME() function or the SYSUTCDATETIME() function (if you want the UTC time). –  mrdenny Jan 26 '11 at 9:11
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.