It seems that the TIMESTAMP
information is encrypted in some way, where the date/time data is somehow encoded in binary. I just want to discover all the rows that were modified today.
相关问题
- sql execution latency when assign to a variable
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
- SQL to Parse a Key-Value String
相关文章
- Entity Framework 4.3.1 failing to create (/open) a
- Code for inserting data into SQL Server database u
- SQL Server 2008 Change Data Capture, who made the
- Delete Every Alternate Row in SQL
- Linux based PHP install connecting to MsSQL Server
- SQL Azure Reset autoincrement
- How do we alias a Sql Server instance name used in
- Is recursion good in SQL Server?
Depending on usage scenario and the scale of precision that you need you can use following technic: As far as TIMESTAMP is something like global counter you can add one global table with 2 columns:
datetime,timestamp
and make some JOB insert values there every N minutes (depending on required precision). Job will insert NOW() into datetime column and current TIMESTAMP value. In this way you get some kind of "time ruler" and you always can determine which timespan your particular TIMESTAMP from another table belongs to. Sample: You have timestamp value 0x000121 and look for timespan, when it was generated. Your table has values
Using select query you will be able to determine, that 0x000121 lies between 20120501 12:30:00 and 20120501 12:45:00
If you have no possibility to create such table/job you can look into database and determine other tables with timestamp and maybe you will be lucky and will find datetime column there as well (filled with NOW()), then you can use that table as "time ruler".
TIMESTAMP is just an incremental, per-row value. It does not hold any actual date/time information.
What you need is for example an actual DATETIME column with its default value set to
GETUTCDATE()
or something like that.TIMESTAMP
is an unfortunate name the SQL Server team gave the data type. It is for concurrency, and has nothing to do with date or time - they've recommended using its alias,ROWVERSION
to prevent confusion. From this Books Online article, "In DDL statements, use rowversion instead of timestamp wherever possible."Unfortunately you won't be able to derive any date/time details from the
ROWVERSION
column you already have, but if this information is important, you should add CreatedDate / ModifiedDate columns, for example:Then create a
TRIGGER
that fires onUPDATE
to keep the ModifiedDate value current. You may need to decide whether you want the ModifiedDate to beNULL
or equal to CreatedDate on initialization.