Skip to main content

Posts

Showing posts from July, 2015

How To Insert Data To A Timestamp Column

It is mentioned in the SQL world that you can’t insert a value into timestamp/rowversion column. But you actually can, I was surprised to find there was no record of this workaround on the internet. That said, I looked no more than 15-20 minutes. This was tested on " SQL Server Edition : 2012 Enterprise". The problem with timestamp is that it doesn’t accept an explicit value to a table Ex.   Create table #Customer ( ID int ( identity(1,1) , Name nvarchar(100), Address nvarchar(1000), LastestVersion  timestamp ) Insert into #Customer (Name , Address , LastestVersion) Select top 500 Name , Address , LastestVersion From  Actual_Customer The above will error out complaining that a explicit value can’t be added to the #Customer table due to rowversion. However if you define the table on the fly with “SELECT INTO”, SQL server is tricked into believing the timestamp column is another jack datatype. SELECT top 500 Name , Address , LastestVersion INTO