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
 New to SQL Server Programming
 error in timestamp

Author  Topic 

handinugraha
Starting Member

8 Posts

Posted - 2010-01-08 : 01:45:53
need help on this issues

"cannot specify a column width on data type timestamp"

here is the line

"DATE_POSTED" TIMESTAMP (6)"

what is the problem with it ?

thanks,




Newbie to SQL Server

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-01-08 : 01:49:38
timestamp in SQL Server is not what it really means. You should use datetime datatype.

refer to http://msdn.microsoft.com/en-us/library/ms182776%28SQL.90%29.aspx



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

jackv
Master Smack Fu Yak Hacker

2179 Posts

Posted - 2010-01-08 : 01:53:04
Just use :DATE_POSTED TIMESTAMP

Jack Vamvas
--------------------
http://www.ITjobfeed.com
Go to Top of Page

handinugraha
Starting Member

8 Posts

Posted - 2010-01-08 : 01:53:50
if i change to datetime it gives me the same error..
or there should another thing i have to change ?
how about value inside the bracket ?
i still havent understood..

thanks



Newbie to SQL Server
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-01-08 : 01:55:49
just

DATE_POSTED datetime

without the ()

Do you have the SQL Server Books Online ? You can refer to it for the syntax etc

here is an online version http://msdn.microsoft.com/en-us/library/ms130214%28SQL.90%29.aspx


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

handinugraha
Starting Member

8 Posts

Posted - 2010-01-08 : 02:00:54
@khtan no i dont have any books..
coz my boss gave me straight away the real database , i dont have time to study on it.. :(

yes it is working without the ()..thanks for the book's link :)



Newbie to SQL Server
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-01-08 : 02:04:13
the SQL Server Books Online is a help file you can installed together with the SQL Server installation. If you don't have it, just google for it and download.


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

handinugraha
Starting Member

8 Posts

Posted - 2010-01-08 : 02:06:51
if i have 2 variables using timestamp, when i execute it was saying that it cant be added because of 1 tables can only have one timestamp column.
how can i add more then ?

thanks

Newbie to SQL Server
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2010-01-08 : 02:11:59
timestamp in Oracle and SQL Server are totally different. timestamp in SQL Server is actually the rowversion. Refer to the link i provided earlier.

You should translate timestamp from oracle to datetime in SQL Server



KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-08 : 02:14:33
quote:
Originally posted by handinugraha

if i have 2 variables using timestamp, when i execute it was saying that it cant be added because of 1 tables can only have one timestamp column.
how can i add more then ?

thanks

Newbie to SQL Server


as suggested before you need to make them datetime. timestamp is just stored as a hex value which is used to represent change of status of record. so use datetime instead.
Go to Top of Page

handinugraha
Starting Member

8 Posts

Posted - 2010-01-08 : 05:09:59
Hmm..how about in the insertion function, can it be used datetime also ?
i ran it and is not recognized..

Newbie to SQL Server
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2010-01-08 : 10:41:03
quote:
Originally posted by handinugraha

Hmm..how about in the insertion function, can it be used datetime also ?
i ran it and is not recognized..

Newbie to SQL Server


nope. you cant insert direct values to timestamp column.
Go to Top of Page
   

- Advertisement -