57

What is difference between datetime and timestamp datatype in Sql Server?.

Kiquenet
  • 14,494
  • 35
  • 148
  • 243
Dr. Rajesh Rolen
  • 14,029
  • 41
  • 106
  • 178
  • 1
    The duplicate question https://stackoverflow.com/questions/7105093/difference-between-datetime-and-timestamp-in-sqlserver has discussions, that may be interesting to read – Michael Freidgeim Dec 13 '17 at 20:32

4 Answers4

47

One is a date and time, the other is a column type that is updated every time a row is updated.

[Note timestamp is being deprecated; use rowversion instead]

Mitch Wheat
  • 295,962
  • 43
  • 465
  • 541
9

Timestamp (deprecated synonym for rowversion) :

Is a data type that exposes automatically generated, unique binary numbers within a database. rowversion is generally used as a mechanism for version-stamping table rows. The storage size is 8 bytes. The rowversion data type is just an incrementing number and does not preserve a date or a time. To record a date or time, use a datetime2 data type.

http://msdn.microsoft.com/en-us/library/ms182776.aspx

A. M.
  • 1,545
  • 9
  • 14
-1

Normally time-stamp used when ever you inserted new record into database automatically system would take default date time ex : transaction like bank deposit or with draw

data-time datatype used at the movement of inserting the user defined date into the record ex : date of birth

-2

timestamp is the synonym for the rowversion data type and is subject to the behavior of data type synonyms. In DDL statements, use rowversion instead of timestamp wherever possible. In simple way to tell, It means the updating time of row. datetime means the time of creation of row. DateTime is constant and other is changeable as the real time and local time.

Riaj Ferdous
  • 863
  • 7
  • 5
  • In some versions of SQL Server, rowversion is the synonym e.g. SQL Server 2005. https://learn.microsoft.com/en-us/previous-versions/sql/sql-server-2005/ms182776(v=sql.90) – Adam Apr 08 '18 at 02:58