question

thesqlguyatl avatar image
thesqlguyatl asked

Can I query data as of a point in time?

Does anyone know if SQL Server has a way to query data as of a point in time similar to Oracle's flashback query? If you aren't familiar with it, flashback query ability allows you to execute a normal select statement with an additional AS OF clause before the where clause to indicate a point in time. This functionality utilizes undo retention and data is only available based on the settings of the undo retention and tablespace restrictions. Example of Oracle's flashback query: SELECT * FROM MYTABLE AS OF TIMESTAMP (SYSDATE - INTERVAL '30' MINUTE);
sqlqueryoracleselect
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
ThomasRushton avatar image
ThomasRushton answered
The only way I can think of doing this in SQL Server is by restoring the database to that point in time, and then querying. Not really the answer you're looking for... If you want to do this, though, when doing the `RESTORE`, make sure that you use the `STOPAT` parameter when doing the `RESTORE LOG`s. For examples of this, see the documentation here: https://msdn.microsoft.com/en-us/library/ms186858.aspx#restoring_to_pit_using_STOPAT
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.