Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Help with SQLServer Timestamp

 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, I created a timestamp field. I'm using SQLServer 2000 but when I INSERT a record, the timestamp field value looks like this...


0x000000000000045E


Why is it like that? It's not quite what I expected... Thanks!
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Transact-SQL timestamp != an ANSI SQL-92 timestamp. If its a SQL style timestamp you are after use a datetime data type. A T-SQL timestamp are just auto generated binary numbers guarenteed to be unique in the context of a database and are typically used for versioning, not storing dates.
 
Timothy Sam
Ranch Hand
Posts: 751
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
so if I use datetime, will I need to input data implicitly (through code) or even when I supply data, it would get the current time for me?
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
datetime is just a data type for storing dates. How you put the date in there is up to you. You could get the date in your application code or you could use SQL Server's current_timestamp function.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic