Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is the database fully recovered

Status
Not open for further replies.

brage98

IS-IT--Management
Sep 8, 2010
27
CA
Is there a view or a property of Microsoft.SqlServer.Management.Smo that'll tell me if a database is already fully recovered?

I'm running a command in powershell to put my database back in recovery mode... however if the database is already fully recovered I get the "The database is already fully recovered" exception...

So what I want is:
Code:
if (NOT Database_Is_Already_Recovered)
{
  RESTORE DATABASE $targetDBName WITH RECOVERY
}

Your help on determining Database_Is_Already_Recovered is much appreciated
 
Try this (untested):

Code:
IF (SELECT state FROM sys.databases WHERE [name] = mydatabase) <> 0
  BEGIN
    RESTORE DATABASE $targetDBName WITH RECOVERY
  END

-SQLBill

The following is part of my signature block and is only intended to be informational.
Posting advice: FAQ481-4875
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top