none
restore database and auto-close command window

    Question

  • I use below batch file to restore database. 

    sqlcmd-U sa -P xxxxx -S localhost -Q "ALTER DATABASE MyDB1 SET SINGLE_USER WITH ROLLBACK IMMEDIATE; 
    RESTORE DATABASE MyDB1 FROM DISK='E:\MyDB1.bak';

    ALTER DATABASE MyDB1 SET MULTI_USER;"

    The database is restored but it leaves a command windows with "1 >" prompt.

    I need to type "exit" to close the command window. How to close the command window automatically?

    many thanks,

    Joe

    Wednesday, January 31, 2018 3:44 AM

Answers

All replies