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.
Suppose we have created OrderHistory table in current database.
CREATE TABLE OrderHistory(
OrderId BIGINT PRIMARY KEY,
OrderDate TIMESTAMP
)
Now if will try to insert some records into the OrderHistory table:
INSERT INTO OrderHistory(OrderId,OrderDate) VALUES(100,GETDATE())
We will get error message :
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.
Cause: We cannot insert explicit value in timestamp column in sql server
Solution:
Correct way to insert :
INSERT INTO OrderHistory(OrderId,OrderDate) VALUES(100,DEFAULT)
Or
INSERT INTO OrderHistory(OrderId) VALUES(100)
No comments:
Post a Comment