Well, I googled using timestamp and sql server and while there was some good advice out there, I never saw an example of how to send that value back to sql and compare it. All the examples showed how to pull it from the database and talked about the necessity of it when wanting to make sure there was no accidental overwrites, etc.
I am here to change that. It seems that the sql server timestamp type can be easily converted into a bigint and vice versa. This simplified a lot of items for me and made the timestamps very human readable.
Any how here is the code snippets:
SQL Server Get Code:
SELECT CAST(a.RowTimestamp AS BIGINT) AS RowTimestamp, ...
SQL Server Update Code:
WHERE RowTimestamp = CAST(@RowTimestamp AS TIMESTAMP)
.NET Property
Private _RowTimestamp as Int64 .... Public Property RowTimestamp() As Int64 Get Return _RowTimestamp End Get Set(ByVal value As Int64) _RowTimestamp = value End Set End Property
.NET Data Access Read
myClass.RowTimestamp = sqlDR.GetInt64(i)
I hope this helps you as it did me.
Robert Wallace
No Slogans, Just Results
I wish i had come to your site eariler. I came to the same conclusion, but you’ ve been helpful in confirming this. thanks.
Hi Wallace,
I am facing an issue in casting this Timestamp to Bigint. like this
set NodeID = cast(RowID(its a timestamp) as bigint). But the problem here is it is generating a value of length 9 characters which was not the case in prior. Every time I am truncating the table before updating like this. But it is used to generate only a numeric value of length 8 only and which is same I am sending it some other down stream application. And they also will accept only the value with length 8. So could you please help me out fixing this issue.
Thanks,
Sarath.
Can you post a code snippet along with other factors (it may not matter)? For exmaple sql version, .net framework, etc.