Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7190493
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T19:31:39+00:00 2026-05-28T19:31:39+00:00

I tried to backup my database following the instruction from SQL Server: Database stuck

  • 0

I tried to backup my database following the instruction from SQL Server: Database stuck in "Restoring" state. but i have my database stuck in “Restoring” state. php code below:

$database = "container";
$uid = "sa";
$pwd = "12345" ; 

try {
      $conn = new PDO( "sqlsrv:Server=localhost\SQLEXPRESS;Database=$database", 
          $uid, 
          $pwd
          //,array(PDO::ATTR_PERSISTENT => true)
          ); 
  $conn->setAttribute( PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION ); }
catch( PDOException $e ) {
  die( "Error connecting to SQL Server" ); }

echo "Connected to SQL Server\n";

$backfile = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\sql server bk' ;
echo "Connected to SQL Server\n";
$backfile = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\sql server bk'  ;

$query = "RESTORE DATABASE child_database FROM DISK = '$backfile' WITH  REPLACE, RECOVERY ";
$conn->exec($query);

After running this code I got my child_database stuck in restoring state.however I copy the sql command

RESTORE DATABASE child_database FROM DISK = 'C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\Backup\sql server bk' WITH  REPLACE, RECOVERY

and run in microsoft sql server management tool it works just fine.

I try to run add php code

$conn->exec("RESTORE DATABASE child_database WITH RECOVERY");

I got an exception.

please help.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T19:31:40+00:00Added an answer on May 28, 2026 at 7:31 pm

    It seems have problem with PDO driver, this problem may be in the ODBC/SNAC layer on which the driver is built. But this database restoring works well with other drivers.
    I tried with sqlsrv and mssql, they worked well.
    For more detail, see Restoring a SQL Server Database from PHP

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried to restore a database in SQL Server 2005 enterprise edition on Windows
Running sql server 2005 I have database A. I am trying to restore from
I had more database and I tried to make backup for them but they
Tried examples from 'php.net' but don't understand what's the problem. Any suggestions? <?php $_SESSION['test']
I am getting following error. Restore failed for Server I have recently upgraded SQL
I have taken backup of SQL Server 2008 DB on server, and download them
I recently moved a database from a 'SQL Server 2005 SP1' instance to 'SQL
Is there an automatic way in SQL Server 2005 to create a database from
We have a production SQL Server 2005 database server with the production version of
I have to make a local copy of a remote SQL Server database. I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.