| 
                                    
                                        |  | SQL Server Error Messages - Msg 273Error MessageServer: 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. CausesThe TIMESTAMPdata type is an 8-byte data type that exposes automatically generated, unique binary numbers within a database.  It is generally used as a mechanism for version-stamping table rows. |  It should be noted that the TIMESTAMPdata type is a synonym ofROWVERSIONdata type and is subject to the behavior of data type synonyms.  TheTIMESTAMPsyntax is deprecated and will be removed in a future version of SQL Server.  In DDL statements, it is suggested to useROWVERSIONinstead ofTIMESTAMPwherever possible.  In the following paragraphs and sample codes,ROWVERSIONwill be used instead ofTIMESTAMP Each database has a counter that is incremented for each insert or update operation that is performed on a table that contains a ROWVERSIONcolumn within the database.  This counter, the databaseROWVERSION, tracks a relative time within a database and not an actual time that can be associated with a clock. A table can only have one ROWVERSIONcolumn.  Every time that a row with aROWVERSIONcolumn is modified or inserted, the incremented databaseROWVERSIONvalue is inserted in theROWVERSIONcolumn.  It should be noted that theROWVERSIONvalue is incremented with anyUPDATEstatement, even if no row values are modified.  As an example, if a column value is 100, and anUPDATEstatement sets the value to the same value of 100, this action is considered an update even though the resulting row value is the same as before and thus theROWVERSIONis incremented. Since the ROWVERSIONcolumn is automatically generated by the database, this error will be encountered if a value is specified to theROWVERSIONcolumn when a new row is inserted into a table that contains aROWVERSIONcolumn. To illustrate, here’s a table that contains a ROWVERSIONcolumn: CREATE TABLE [dbo].[Team] (
    [TeamID]     INT NOT NULL PRIMARY KEY IDENTITY(1, 1),
    [TeamName]   VARCHAR(50),
    [RowVersion] ROWVERSION )
GO
 Inserting a new row in this table and specifying a value to the timestamp column will generate this error: INSERT INTO [dbo].[Team] ( [TeamName], [RowVersion] )
VALUES ( 'Detroit Tigers', @@DBTS ),
       ( 'Houston Astros', @@DBTS ),
       ( 'Kansas City Royals', @@DBTS ),
       ( 'Los Angeles Dodgers', @@DBTS ),
       ( 'Miami Marlins', @@DBTS ),
       ( 'New York Yankees', @@DBTS )
GO
 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.
   Figure 1: Error Message 273 - Cannot insert an explicit value into a TIMESTAMP column.The @@DBTSsystem function returns the value of the current or last-usedROWVERSIONvalue for the current database. The current database will have a guaranteed uniqueROWVERSIONvalue. Solution / Work AroundThere are 2 ways of working around this issue, as the error message suggests. Option #1 - Exclude ROWVERSIONColumn inINSERTStatementThe first method is not to include the ROWVERSIONcolumn in the list of columns specified in theINSERTstatement: INSERT INTO [dbo].[Team] ( [TeamName] )
VALUES ( 'Detroit Tigers' ),
       ( 'Houston Astros' ),
       ( 'Kansas City Royals' ),
       ( 'Los Angeles Dodgers' ),
       ( 'Miami Marlins' ),
       ( 'New York Yankees' )
GO
SELECT * FROM [dbo].[Team]
GO
 | TeamID | TeamName            | RowVersion |
|--------|---------------------|------------|
|      1 | Detroit Tigers      | Ó          |
|      2 | Houston Astros      | Ô          |
|      3 | Kansas City Royals  | Õ          |
|      4 | Los Angeles Dodgers | Ö          |
|      5 | Miami Marlins       | ×          |
|      6 | New York Yankees    | Ø          |
   Figure 2: Error Message 273 - Solution #1 - Exclude ROWVERSIONColumn inINSERTStatementOption #2 - Use DEFAULTValueThe second method is to specify DEFAULTas the value in theROWVERSIONcolumn, as can be seen in the following statement: INSERT INTO [dbo].[Team] ( [TeamName], [RowVersion] )
VALUES ( 'Detroit Tigers', DEFAULT ),
       ( 'Houston Astros', DEFAULT ),
       ( 'Kansas City Royals', DEFAULT ),
       ( 'Los Angeles Dodgers', DEFAULT ),
       ( 'Miami Marlins', DEFAULT ),
       ( 'New York Yankees', DEFAULT )
GO
SELECT * FROM [dbo].[Team]
GO
 | TeamID | TeamName            | RowVersion |
|--------|---------------------|------------|
|      1 | Detroit Tigers      | Ù          |
|      2 | Houston Astros      | Ú          |
|      3 | Kansas City Royals  | Û          |
|      4 | Los Angeles Dodgers | Ü          |
|      5 | Miami Marlins       | Ý          |
|      6 | New York Yankees    | Þ          |
   Figure 3: Error Message 273 - Solution #2 - Use DEFAULTValueThe ROWVERSIONcolumn of a row can be used to easily determine whether any value in the row has changed since the last time it was read.  If any change is made to the row, theROWVERSIONvalue is updated.  If no change is made to the row, theROWVERSIONvalue is the same as when it was previously read. |