How to validate if a database has been restored

I have a huge database (Call it DbTwo). DbTwo was created from another database named "dbOne".Basically dbOne was backed up into dbTwo.

Is their a way in Query analyzer to determine when dbTwo was restored/created from dbOne? Part of the plan here is to validate that the data is the same if both databases have not yet been updated within the past day or two.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David ToddSenior Database AdministratorCommented:

Redgate makes two different tools - one compares schemas and the other data. Possibly for your compare you need this tool.

Otherwise a quick and dirty is something like
sp_MSForEachTable "select count(  * ) as ""?"" from ?"

Of course this could be refined so results are returned via a table and in one results set and ordered on tablename ...


Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
brgdotnetcontractorAuthor Commented:
Thank you David. I am looking for something even quicker. Let's suppose I just want to verify that database DbTwo was created on todays date. How would I do that? Really that is what I am after, just proving to myself that it is a copy of DbOne and it was create today. Is their a way to do that?
So sorry I did not ask that before.
David ToddSenior Database AdministratorCommented:

Maybe then, just check the filedate on the datafiles.

I don't think restores are logged the same way backups are in MSDB.

I think the create date retains the original date, and is not updated with the restore datetime.

Vitor MontalvãoMSSQL Senior EngineerCommented:
This will return information about a database including the created date:
EXEC sp_helpdb 'DbTwo'

Open in new window

Scott PletcherSenior DBACommented:
If the db was actually created at that time, you can do:

SELECT create_date, * FROM sys.databases WHERE name = 'DbOne'

If DbOne was restored from a backup, you can use table msdb.dbo.restorehistory to see the date and time of the restore, which tells you the most recent restore even if it was over an existing db.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.