Wednesday, March 7, 2012

Database Restore error

Hi,
When I am using following script, I am getting an error message
ALTER DATABASE mydb SET SINGLE_USER WITH ROLLBACK IMMEDIATE
RESTORE DATABASE mydb FROM DISK
='\\myServer\c$\backup\mydb_oltp\mydb_ol
tp_db_200608062107.BAK'
Server: Msg 3101, Level 16, State 1, Line 1
Exclusive access could not be obtained because the database is in use.
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.
I am setting up the db with single mode and no one else is using the
db.. why am I getting this error?
Thank you,
hjAll right I got it. The cursor was still positioned on mydb in my Query
Analyzer.
I changed that and it worked like a charm... I have to make this work
inside a Python file now.
Thanks all...
hj
Hitesh wrote:
> Hi,
> When I am using following script, I am getting an error message
> ALTER DATABASE mydb SET SINGLE_USER WITH ROLLBACK IMMEDIATE
> RESTORE DATABASE mydb FROM DISK
> ='\\myServer\c$\backup\mydb_oltp\mydb_ol
tp_db_200608062107.BAK'
>
> Server: Msg 3101, Level 16, State 1, Line 1
> Exclusive access could not be obtained because the database is in use.
> Server: Msg 3013, Level 16, State 1, Line 1
> RESTORE DATABASE is terminating abnormally.
> I am setting up the db with single mode and no one else is using the
> db.. why am I getting this error?
> Thank you,
> hj|||Hitesh wrote:
> All right I got it. The cursor was still positioned on mydb in my Query
> Analyzer.
> I changed that and it worked like a charm... I have to make this work
> inside a Python file now.
> Thanks all...
> hj
>
At the beginning of the script, before the ALTER statement, do:
USE master
Tracy McKibben
MCDBA
http://www.realsqlguy.com|||I am getting following error inside Python when I use "USE Master"
[Microsoft][ODBC SQL Server Driver][SQL Server]Changed database
context
to 'master'. in EXEC
here is the query:
qry_restore = """USE Master
ALTER DATABASE mydbtemp SET SINGLE_USER WITH
ROLLBACK IMMEDIATE
RESTORE DATABASE mydbtemp FROM DISK =""" +
restore_path + """
ALTER DATABASE mydbtemptemp SET MULTI_USER"""
hj
Tracy McKibben wrote:
> Hitesh wrote:
> At the beginning of the script, before the ALTER statement, do:
> USE master
>
> --
> Tracy McKibben
> MCDBA
> http://www.realsqlguy.com|||That's an informational message, not an error message, which
can be ignored. You'd need to handle informational messages
in your app.
-Sue
On 9 Aug 2006 13:07:45 -0700, "Hitesh" <hitesh287@.gmail.com>
wrote:
[vbcol=seagreen]
>I am getting following error inside Python when I use "USE Master"
>[Microsoft][ODBC SQL Server Driver][SQL Server]Changed database
context
>to 'master'. in EXEC
>here is the query:
> qry_restore = """USE Master
> ALTER DATABASE mydbtemp SET SINGLE_USER WITH
>ROLLBACK IMMEDIATE
> RESTORE DATABASE mydbtemp FROM DISK =""" +
>restore_path + """
> ALTER DATABASE mydbtemptemp SET MULTI_USER"""
>hj
>
>Tracy McKibben wrote:

No comments:

Post a Comment