Cannot update a timestamp column

Error Message:
Msg 272, Level 16, State 1, Line 4
Cannot update a timestamp column.

Severity level:
16.

Description:
This error message appears when you try to update a table column of type TIMESTAMP.

Consequences:
The T-SQL statement can be parsed, but causes the error at runtime.

Resolution:
Error of the Severity Level 16 are generated by the user and can be fixed by the SQL Server user. You cannot modify values in a column of type TIMESTAMP with an UPDATE statement. These values are generated and modified by SQL Server.

Versions:
All versions of SQL Server

Example(s):
USE tempdb
GO
CREATE TABLE #t
(
 TIMESTAMP
)

INSERT INTO #t DEFAULT VALUES
GO
SELECT *
  FROM #t

UPDATE #t
   SET TIMESTAMP = TIMESTAMP + CAST(1 AS BINARY(8)) 
DROP TABLE #t

Remarks:
The data type TIMESTAMP has nothing to do with DATE, TIME, or a combination of both values. Values of type TIMESTAMP are binary numbers. The synonym ROWVERSION is a much clearer description for this data type.




Array

No comments yet... Be the first to leave a reply!