Reputation: 21
I have a time stamp field in a table and I've unticked the box in designer for allowing Nulls I'm unable to enter anything in default value and binding field ( this is greyed out and doesn't allow you type anything ) I'm trying all my sql experiments out in the query designer of sql server express 2008
If I Insert a new record into the table the timestamp field gives a value that looks like: 0x00000000000007D7
As you can see this is totally unreadable:
How can I get round this/ get a readable time stamp in there?
Upvotes: 2
Views: 7744
Reputation: 24022
Use DATETIME
with a default constraint of GETDATE
You can do that like this:
CREATE TABLE myTable
(
ID INT IDENTITY(1,1) PRIMARY KEY CLUSTERED,
myTimeStamp datetime NOT NULL DEFAULT GETDATE()
)
TIMESTAMP
is a binary field used for row versioning and cannot be edited.
From BOL:
timestamp is a data type that exposes automatically generated binary numbers, which are guaranteed to be unique within a database. timestamp is used typically as a mechanism for version-stamping table rows. The storage size is 8 bytes.
Upvotes: 4