-
April 29th, 2005, 01:43 AM
#1
timestamp data type in MSSQL
1. is it use in real world application?
2. what is it for?
now i'm doing the SELECT CAST(@@DBTS AS datetime) and the result is 1900-01-01 00:00:07.053, the value just not make sense to me
thx
-
April 29th, 2005, 04:09 AM
#2
Re: timestamp data type in MSSQL
timestamp (for example from @@DBTS) is guaranteed to be unique in database (wheras GetDate() not). It has "rowversion" alias which better describe its usage. It is a "mark" that U can use to indicate that row has changed.
So timestamp can be used in manual optimistic row locking or in merge operation. Casting timestamp to datetime has no sense (it is more like GUID but with database scope).
Best regards,
Krzemo.
-
April 29th, 2005, 04:35 AM
#3
Re: timestamp data type in MSSQL
thanks Krzemo
as far as i understand that every time we update the database that have timestamp value, it'll automatic update the timestamp field too..
It is a "mark" that U can use to indicate that row has changed.
by using the select @@DBTS it's only shown the binary value..is it possible to know which row from which table that has changed? how?
Casting timestamp to datetime has no sense (it is more like GUID but with database scope).
coz i'm not sure how to read the 'real' value that represented by those binary (if it's possible)
PS : sorry, new to MS SQL
thanks
-
April 29th, 2005, 07:54 AM
#4
Re: timestamp data type in MSSQL
as far as i understand that every time we update the database that have timestamp value, it'll automatic update the timestamp field too..
Yes.
by using the select @@DBTS it's only shown the binary value..is it possible to know which row from which table that has changed?
No it is auto-generated binary value. But it doesn't matter - U have to find if data has changed or not so U only check if it is equal to that U read before (if not than data has changed for sure).
coz i'm not sure how to read the 'real' value that represented by those binary (if it's possible)
What for?
Don't mix timestamp with "SQL-92 timestamp" datatype.
The "SQL-92 timestamp" datatype is equal to "DATETIME" in SQL Server.
In new SQL Server releases timestamp will be renamed to "rowversion" and "DATETIME" will be renamed to timestamp (to ensure standards) so if U want 2 use timestamp use "rowversion" alias instead (to prevent confusion when U upgrade server)
Hope that helps.
-
April 30th, 2005, 08:17 PM
#5
Re: timestamp data type in MSSQL
Read this from SQL BOL and try to chang from using timestamp to rowversion so when they change the funtion in the future it will not impact you.
http://msdn.microsoft.com/library/de...ta-tz_6fn4.asp
-
May 2nd, 2005, 01:16 AM
#6
Re: timestamp data type in MSSQL
thanks Krzemo and antares686
to compare which value is the latest one..but it already been answered by u..
thanks for the tip from both of u
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|