July 26, 2011 at 8:17 am
By accident, I deleted two records.
I tried to insert these two records from the backup table but got an error below. How to do it?
Cannot insert a non-null value into a timestamp column
July 26, 2011 at 8:23 am
the name timestamp column is very misleading...it's synonym of ROWVERSION is more descriptive.
change your insert to not include the timestamp column...a new value will be created for you automaticaly, just like an IDENTITY() column would.
Lowell
July 26, 2011 at 3:01 pm
This snipet will show you what a timestamp looks like when allowing the system to generate on the insert.
USE tempdb;
go
CREATE TABLE stamp_test(
TestDate DATETIME NOT NULL,
TestStamp TIMESTAMP
);
GO
SET NOCOUNT ON;
INSERT INTO stamp_test (TestDate) VALUES ('October 10, 2005');
INSERT INTO stamp_test (TestDate) VALUES ('November 10, 2005 10:01:01');
INSERT INTO stamp_test (TestDate) VALUES ('December 6, 2005 11:01:01');
INSERT INTO stamp_test (TestDate) VALUES ('January 5, 2006');
INSERT INTO stamp_test (TestDate) VALUES ('02/07/2006');
INSERT INTO stamp_test (TestDate) VALUES ('03/08/2006 14:01:01');
INSERT INTO stamp_test (TestDate) VALUES ('04/06/2006 15:01:01');
INSERT INTO stamp_test (TestDate) VALUES ('20060504');
INSERT INTO stamp_test (TestDate) VALUES ('20060606 17:01:01');
INSERT INTO stamp_test (TestDate) VALUES ('20060706 19:01:01');
SET NOCOUNT OFF;
GO
SELECT *
FROM stamp_test;
GO
John Miner
Crafty DBA
www.craftydba.com
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply