Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Script Library
 TIMESTAMP problem when using insert script

Author  Topic 

froggiejun
Starting Member

3 Posts

Posted - 2010-06-24 : 01:35:46
Hi all,

i am facing a problem when i insert some data into SQL server. The problem is i not able to insert the date time into the TimeStamp column.
My statement shown at below,

Insert into USERS(USER_ID,USER_NAME,Last_Update_Timestamp)
VALUES('1001','JOHN',CONVERT(TIMESTAMP,'1996-06-26 9:30:00.000',121));

The error shown that, 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.


Someone please help my in this problem. Thanks.

Lumbago
Norsk Yak Master

3271 Posts

Posted - 2010-06-24 : 02:43:04
"Timestamp" is a special data type that is rarely used, run this in management studio and see how it looks:
declare @table table (
id int,
timest timestamp)
insert into @table (id) select 1

select * from @table
What you're looking for is "datetime". This will probably work (just make sure to change the data type of the Last_Update_Timestamp to datetime also):
Insert into USERS(USER_ID,USER_NAME,Last_Update_Timestamp)
VALUES('1001','JOHN',CONVERT(datetime,'1996-06-26 9:30:00.000'))


- Lumbago

My blog (yes, I have a blog now! just not that much content yet)
-> www.thefirstsql.com
Go to Top of Page

froggiejun
Starting Member

3 Posts

Posted - 2010-06-24 : 02:49:31
Thank you...
Go to Top of Page
   

- Advertisement -