SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 TIMESTAMP problem when using insert script
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

froggiejun
Starting Member

Malaysia
3 Posts

Posted - 06/24/2010 :  01:35:46  Show Profile  Reply with Quote
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

Norway
3271 Posts

Posted - 06/24/2010 :  02:43:04  Show Profile  Reply with Quote
"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

Malaysia
3 Posts

Posted - 06/24/2010 :  02:49:31  Show Profile  Reply with Quote
Thank you...
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.05 seconds. Powered By: Snitz Forums 2000