Cannot insert an explicit value into a timestamp column. Use INSERT with a column list to exclude the timestamp column, or insert a DEFAULT into the timestamp column.

Error Message:
Msg 273, Level 16, State 1, Line 1
Cannot insert an explicit value into a timestamp column. Use INSERT with a column list to exclude the timestamp column, or insert a DEFAULT into the timestamp column.

Severity level:
16.

Description:
This error message appears when insert an explicit value into a column if 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. The statement cannot be executed this way. You cannot explicitly insert values into a column of the TIMESTAMP data type. You must use an INSERT statement with a column list that excludes the TIMESTAMP column.

Versions:
All versions of SQL Server.

Example(s):
USE tempdb;
GO
DECLARE @t VARCHAR(10)
IF OBJECT_ID(‘tempdb..#t’) > 0
 DROP TABLE #t
GO
CREATE TABLE #t
(
 c1 TIMESTAMP PRIMARY KEY
)
GO
INSERT INTO #t SELECT 1
UNION ALL SELECT 2
GO
SELECT TOP(1e2) *
  FROM #t

Remarks:
In the above example we try to insert explicitly a value into the column c1 of the table #t. Because this column is of type TIMESTAMP, the error is raised.

]]>

Leave a comment

Your email address will not be published.