I created script that would restore db automatically, but i have problem
running ...
i get error
Server: Msg 3101, Level 16, State 1, Line 2
Exclusive access could not be obtained because the database is in use.
Server: Msg 3013, Level 16, State 1, Line 2
RESTORE DATABASE is terminating abnormally.
HOW do i modify this script to kill all users who use EAGLE database before
restoring database ?
USE EAGLE
GO
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
WITH
MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
,REPLACE
GO
Mikus
Lookup SINGLE USER MODE in the BOL.
"Mikus" <Mikus@.discussions.microsoft.com> wrote in message
news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
>I created script that would restore db automatically, but i have problem
> running ...
> i get error
> Server: Msg 3101, Level 16, State 1, Line 2
> Exclusive access could not be obtained because the database is in use.
> Server: Msg 3013, Level 16, State 1, Line 2
> RESTORE DATABASE is terminating abnormally.
> HOW do i modify this script to kill all users who use EAGLE database
> before
> restoring database ?
> USE EAGLE
> GO
> RESTORE DATABASE EAGLE
> FROM DISK = 'E:\DBbackup\dailybuild.bck'
> WITH
> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> ,REPLACE
> GO
|||> USE EAGLE
> GO
> RESTORE DATABASE EAGLE
Above will *not* work. You enter the eagle database yourself, and block the restore yourself. USE
master and then restore instead. Also, use ALTER DATABASE to se the database in single user mode,
having the ROLLBACK option to get rid of other users.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Mikus" <Mikus@.discussions.microsoft.com> wrote in message
news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
>I created script that would restore db automatically, but i have problem
> running ...
> i get error
> Server: Msg 3101, Level 16, State 1, Line 2
> Exclusive access could not be obtained because the database is in use.
> Server: Msg 3013, Level 16, State 1, Line 2
> RESTORE DATABASE is terminating abnormally.
> HOW do i modify this script to kill all users who use EAGLE database before
> restoring database ?
> USE EAGLE
> GO
> RESTORE DATABASE EAGLE
> FROM DISK = 'E:\DBbackup\dailybuild.bck'
> WITH
> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> ,REPLACE
> GO
|||WHERE do i put ALTER DATABASE clause ?
this way ?
USE MASTER
GO
ALTER DATABASE
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
WITH
MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
,REPLACE
GO
"Tibor Karaszi" wrote:
> Above will *not* work. You enter the eagle database yourself, and block the restore yourself. USE
> master and then restore instead. Also, use ALTER DATABASE to se the database in single user mode,
> having the ROLLBACK option to get rid of other users.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
>
>
|||You need to read Books Online to see how to execute ALTER DATABASE (SINGLE USER, ROLBACK etc). But,
yes, you put it before your RESTORE command.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Mikus" <Mikus@.discussions.microsoft.com> wrote in message
news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...[vbcol=seagreen]
> WHERE do i put ALTER DATABASE clause ?
> this way ?
> USE MASTER
> GO
> ALTER DATABASE
> RESTORE DATABASE EAGLE
> FROM DISK = 'E:\DBbackup\dailybuild.bck'
> WITH
> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> ,REPLACE
> GO
> "Tibor Karaszi" wrote:
|||To automate the restore, I usually kill connected users then run the restore.
I have a stored procedure KillConn in master database which I always call
whenever I need to automate database restore. KillConn accepts a parameter
which is database name.
EXEC Master.dbo.KillConn 'Eagle'
go
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
....................................
Here is the extract of KillConn stored procedure:
CREATE PROCEDURE KillConn (@.db varchar(30))
AS
DECLARE @.ps VARCHAR(255)
DECLARE @.id smallint
DECLARE c CURSOR FOR
SELECT
DISTINCT
spid
FROM
master..sysprocesses
WHERE
dbid
IN
(SELECT
dbid
FROM
master..sysdatabases
WHERE
name
IN
(@.db))
OPEN c
FETCH NEXT FROM c INTO @.id
WHILE (@.@.FETCH_STATUS <> -1)
BEGIN
SELECT @.ps = 'KILL ' + CONVERT(VARCHAR(8), @.id)
EXEC(@.ps)
FETCH NEXT FROM c INTO @.id
END
CLOSE c
DEALLOCATE c
GO
"Tibor Karaszi" wrote:
> You need to read Books Online to see how to execute ALTER DATABASE (SINGLE USER, ROLBACK etc). But,
> yes, you put it before your RESTORE command.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
>
>
|||This was not working ...
USE MASTER
GO
ALTER DATABASE EAGLE
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
WITH
MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
,REPLACE
GO
Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'RESTORE'.
i couldn't really find any info in server books online regarding SINGLE USER
MODE ?
"Tibor Karaszi" wrote:
> You need to read Books Online to see how to execute ALTER DATABASE (SINGLE USER, ROLBACK etc). But,
> yes, you put it before your RESTORE command.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
>
>
|||Hi,
The exact command is:-
ALTER DATABASE EAGLE SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
Now issue the RESTORE database command. After the restore issue the below
command to make database multi user.
go
ALTER DATABASE EAGLE SET MULTI_USER
Thanks
Hari
SQL Server MVP
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:er0BvN6sFHA.2008@.TK2MSFTNGP10.phx.gbl...
> You need to read Books Online to see how to execute ALTER DATABASE (SINGLE
> USER, ROLBACK etc). But, yes, you put it before your RESTORE command.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
>
|||Thanks a lot HAri
"Hari Prasad" wrote:
> Hi,
> The exact command is:-
> ALTER DATABASE EAGLE SET SINGLE_USER WITH ROLLBACK IMMEDIATE
> GO
> Now issue the RESTORE database command. After the restore issue the below
> command to make database multi user.
> go
> ALTER DATABASE EAGLE SET MULTI_USER
> Thanks
> Hari
> SQL Server MVP
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
> message news:er0BvN6sFHA.2008@.TK2MSFTNGP10.phx.gbl...
>
>
Showing posts with label msg. Show all posts
Showing posts with label msg. Show all posts
Wednesday, March 28, 2012
Restore DB automatically
Labels:
2exclusive,
automatically,
created,
database,
errorserver,
level,
line,
microsoft,
msg,
mysql,
oracle,
problemrunning,
restore,
script,
server,
sql,
state
Restore DB automatically
I created script that would restore db automatically, but i have problem
running ...
i get error
Server: Msg 3101, Level 16, State 1, Line 2
Exclusive access could not be obtained because the database is in use.
Server: Msg 3013, Level 16, State 1, Line 2
RESTORE DATABASE is terminating abnormally.
HOW do i modify this script to kill all users who use EAGLE database before
restoring database ?
USE EAGLE
GO
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
WITH
MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
,REPLACE
GOMikus
Lookup SINGLE USER MODE in the BOL.
"Mikus" <Mikus@.discussions.microsoft.com> wrote in message
news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
>I created script that would restore db automatically, but i have problem
> running ...
> i get error
> Server: Msg 3101, Level 16, State 1, Line 2
> Exclusive access could not be obtained because the database is in use.
> Server: Msg 3013, Level 16, State 1, Line 2
> RESTORE DATABASE is terminating abnormally.
> HOW do i modify this script to kill all users who use EAGLE database
> before
> restoring database ?
> USE EAGLE
> GO
> RESTORE DATABASE EAGLE
> FROM DISK = 'E:\DBbackup\dailybuild.bck'
> WITH
> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> ,REPLACE
> GO|||> USE EAGLE
> GO
> RESTORE DATABASE EAGLE
Above will *not* work. You enter the eagle database yourself, and block the
restore yourself. USE
master and then restore instead. Also, use ALTER DATABASE to se the database
in single user mode,
having the ROLLBACK option to get rid of other users.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Mikus" <Mikus@.discussions.microsoft.com> wrote in message
news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
>I created script that would restore db automatically, but i have problem
> running ...
> i get error
> Server: Msg 3101, Level 16, State 1, Line 2
> Exclusive access could not be obtained because the database is in use.
> Server: Msg 3013, Level 16, State 1, Line 2
> RESTORE DATABASE is terminating abnormally.
> HOW do i modify this script to kill all users who use EAGLE database befor
e
> restoring database ?
> USE EAGLE
> GO
> RESTORE DATABASE EAGLE
> FROM DISK = 'E:\DBbackup\dailybuild.bck'
> WITH
> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> ,REPLACE
> GO|||WHERE do i put ALTER DATABASE clause ?
this way ?
USE MASTER
GO
ALTER DATABASE
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
WITH
MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
,REPLACE
GO
"Tibor Karaszi" wrote:
> Above will *not* work. You enter the eagle database yourself, and block th
e restore yourself. USE
> master and then restore instead. Also, use ALTER DATABASE to se the databa
se in single user mode,
> having the ROLLBACK option to get rid of other users.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
>
>|||You need to read Books Online to see how to execute ALTER DATABASE (SINGLE U
SER, ROLBACK etc). But,
yes, you put it before your RESTORE command.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Mikus" <Mikus@.discussions.microsoft.com> wrote in message
news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...[vbcol=seagreen]
> WHERE do i put ALTER DATABASE clause ?
> this way ?
> USE MASTER
> GO
> ALTER DATABASE
> RESTORE DATABASE EAGLE
> FROM DISK = 'E:\DBbackup\dailybuild.bck'
> WITH
> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> ,REPLACE
> GO
> "Tibor Karaszi" wrote:
>|||To automate the restore, I usually kill connected users then run the restore
.
I have a stored procedure KillConn in master database which I always call
whenever I need to automate database restore. KillConn accepts a parameter
which is database name.
EXEC Master.dbo.KillConn 'Eagle'
go
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
...................................
Here is the extract of KillConn stored procedure:
CREATE PROCEDURE KillConn (@.db varchar(30))
AS
DECLARE @.ps VARCHAR(255)
DECLARE @.id smallint
DECLARE c CURSOR FOR
SELECT
DISTINCT
spid
FROM
master..sysprocesses
WHERE
dbid
IN
(SELECT
dbid
FROM
master..sysdatabases
WHERE
name
IN
(@.db))
OPEN c
FETCH NEXT FROM c INTO @.id
WHILE (@.@.FETCH_STATUS <> -1)
BEGIN
SELECT @.ps = 'KILL ' + CONVERT(VARCHAR(8), @.id)
EXEC(@.ps)
FETCH NEXT FROM c INTO @.id
END
CLOSE c
DEALLOCATE c
GO
"Tibor Karaszi" wrote:
> You need to read Books Online to see how to execute ALTER DATABASE (SINGLE
USER, ROLBACK etc). But,
> yes, you put it before your RESTORE command.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
>
>|||This was not working ...
USE MASTER
GO
ALTER DATABASE EAGLE
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
WITH
MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
,REPLACE
GO
Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'RESTORE'.
i couldn't really find any info in server books online regarding SINGLE USER
MODE ?
"Tibor Karaszi" wrote:
> You need to read Books Online to see how to execute ALTER DATABASE (SINGLE
USER, ROLBACK etc). But,
> yes, you put it before your RESTORE command.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
>
>|||Hi,
The exact command is:-
ALTER DATABASE EAGLE SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
Now issue the RESTORE database command. After the restore issue the below
command to make database multi user.
go
ALTER DATABASE EAGLE SET MULTI_USER
Thanks
Hari
SQL Server MVP
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:er0BvN6sFHA.2008@.TK2MSFTNGP10.phx.gbl...
> You need to read Books Online to see how to execute ALTER DATABASE (SINGLE
> USER, ROLBACK etc). But, yes, you put it before your RESTORE command.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
>|||Thanks a lot HAri
"Hari Prasad" wrote:
> Hi,
> The exact command is:-
> ALTER DATABASE EAGLE SET SINGLE_USER WITH ROLLBACK IMMEDIATE
> GO
> Now issue the RESTORE database command. After the restore issue the below
> command to make database multi user.
> go
> ALTER DATABASE EAGLE SET MULTI_USER
> Thanks
> Hari
> SQL Server MVP
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote i
n
> message news:er0BvN6sFHA.2008@.TK2MSFTNGP10.phx.gbl...
>
>sql
running ...
i get error
Server: Msg 3101, Level 16, State 1, Line 2
Exclusive access could not be obtained because the database is in use.
Server: Msg 3013, Level 16, State 1, Line 2
RESTORE DATABASE is terminating abnormally.
HOW do i modify this script to kill all users who use EAGLE database before
restoring database ?
USE EAGLE
GO
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
WITH
MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
,REPLACE
GOMikus
Lookup SINGLE USER MODE in the BOL.
"Mikus" <Mikus@.discussions.microsoft.com> wrote in message
news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
>I created script that would restore db automatically, but i have problem
> running ...
> i get error
> Server: Msg 3101, Level 16, State 1, Line 2
> Exclusive access could not be obtained because the database is in use.
> Server: Msg 3013, Level 16, State 1, Line 2
> RESTORE DATABASE is terminating abnormally.
> HOW do i modify this script to kill all users who use EAGLE database
> before
> restoring database ?
> USE EAGLE
> GO
> RESTORE DATABASE EAGLE
> FROM DISK = 'E:\DBbackup\dailybuild.bck'
> WITH
> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> ,REPLACE
> GO|||> USE EAGLE
> GO
> RESTORE DATABASE EAGLE
Above will *not* work. You enter the eagle database yourself, and block the
restore yourself. USE
master and then restore instead. Also, use ALTER DATABASE to se the database
in single user mode,
having the ROLLBACK option to get rid of other users.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Mikus" <Mikus@.discussions.microsoft.com> wrote in message
news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
>I created script that would restore db automatically, but i have problem
> running ...
> i get error
> Server: Msg 3101, Level 16, State 1, Line 2
> Exclusive access could not be obtained because the database is in use.
> Server: Msg 3013, Level 16, State 1, Line 2
> RESTORE DATABASE is terminating abnormally.
> HOW do i modify this script to kill all users who use EAGLE database befor
e
> restoring database ?
> USE EAGLE
> GO
> RESTORE DATABASE EAGLE
> FROM DISK = 'E:\DBbackup\dailybuild.bck'
> WITH
> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> ,REPLACE
> GO|||WHERE do i put ALTER DATABASE clause ?
this way ?
USE MASTER
GO
ALTER DATABASE
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
WITH
MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
,REPLACE
GO
"Tibor Karaszi" wrote:
> Above will *not* work. You enter the eagle database yourself, and block th
e restore yourself. USE
> master and then restore instead. Also, use ALTER DATABASE to se the databa
se in single user mode,
> having the ROLLBACK option to get rid of other users.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
>
>|||You need to read Books Online to see how to execute ALTER DATABASE (SINGLE U
SER, ROLBACK etc). But,
yes, you put it before your RESTORE command.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Mikus" <Mikus@.discussions.microsoft.com> wrote in message
news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...[vbcol=seagreen]
> WHERE do i put ALTER DATABASE clause ?
> this way ?
> USE MASTER
> GO
> ALTER DATABASE
> RESTORE DATABASE EAGLE
> FROM DISK = 'E:\DBbackup\dailybuild.bck'
> WITH
> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> ,REPLACE
> GO
> "Tibor Karaszi" wrote:
>|||To automate the restore, I usually kill connected users then run the restore
.
I have a stored procedure KillConn in master database which I always call
whenever I need to automate database restore. KillConn accepts a parameter
which is database name.
EXEC Master.dbo.KillConn 'Eagle'
go
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
...................................
Here is the extract of KillConn stored procedure:
CREATE PROCEDURE KillConn (@.db varchar(30))
AS
DECLARE @.ps VARCHAR(255)
DECLARE @.id smallint
DECLARE c CURSOR FOR
SELECT
DISTINCT
spid
FROM
master..sysprocesses
WHERE
dbid
IN
(SELECT
dbid
FROM
master..sysdatabases
WHERE
name
IN
(@.db))
OPEN c
FETCH NEXT FROM c INTO @.id
WHILE (@.@.FETCH_STATUS <> -1)
BEGIN
SELECT @.ps = 'KILL ' + CONVERT(VARCHAR(8), @.id)
EXEC(@.ps)
FETCH NEXT FROM c INTO @.id
END
CLOSE c
DEALLOCATE c
GO
"Tibor Karaszi" wrote:
> You need to read Books Online to see how to execute ALTER DATABASE (SINGLE
USER, ROLBACK etc). But,
> yes, you put it before your RESTORE command.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
>
>|||This was not working ...
USE MASTER
GO
ALTER DATABASE EAGLE
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
WITH
MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
,REPLACE
GO
Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'RESTORE'.
i couldn't really find any info in server books online regarding SINGLE USER
MODE ?
"Tibor Karaszi" wrote:
> You need to read Books Online to see how to execute ALTER DATABASE (SINGLE
USER, ROLBACK etc). But,
> yes, you put it before your RESTORE command.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
>
>|||Hi,
The exact command is:-
ALTER DATABASE EAGLE SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
Now issue the RESTORE database command. After the restore issue the below
command to make database multi user.
go
ALTER DATABASE EAGLE SET MULTI_USER
Thanks
Hari
SQL Server MVP
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:er0BvN6sFHA.2008@.TK2MSFTNGP10.phx.gbl...
> You need to read Books Online to see how to execute ALTER DATABASE (SINGLE
> USER, ROLBACK etc). But, yes, you put it before your RESTORE command.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
>|||Thanks a lot HAri
"Hari Prasad" wrote:
> Hi,
> The exact command is:-
> ALTER DATABASE EAGLE SET SINGLE_USER WITH ROLLBACK IMMEDIATE
> GO
> Now issue the RESTORE database command. After the restore issue the below
> command to make database multi user.
> go
> ALTER DATABASE EAGLE SET MULTI_USER
> Thanks
> Hari
> SQL Server MVP
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote i
n
> message news:er0BvN6sFHA.2008@.TK2MSFTNGP10.phx.gbl...
>
>sql
Labels:
2exclusive,
automatically,
created,
database,
errorserver,
level,
line,
microsoft,
msg,
mysql,
oracle,
problemrunning,
restore,
script,
server,
sql,
state
Restore DB automatically
I created script that would restore db automatically, but i have problem
running ...
i get error
Server: Msg 3101, Level 16, State 1, Line 2
Exclusive access could not be obtained because the database is in use.
Server: Msg 3013, Level 16, State 1, Line 2
RESTORE DATABASE is terminating abnormally.
HOW do i modify this script to kill all users who use EAGLE database before
restoring database ?
USE EAGLE
GO
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
WITH
MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
,REPLACE
GOMikus
Lookup SINGLE USER MODE in the BOL.
"Mikus" <Mikus@.discussions.microsoft.com> wrote in message
news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
>I created script that would restore db automatically, but i have problem
> running ...
> i get error
> Server: Msg 3101, Level 16, State 1, Line 2
> Exclusive access could not be obtained because the database is in use.
> Server: Msg 3013, Level 16, State 1, Line 2
> RESTORE DATABASE is terminating abnormally.
> HOW do i modify this script to kill all users who use EAGLE database
> before
> restoring database ?
> USE EAGLE
> GO
> RESTORE DATABASE EAGLE
> FROM DISK = 'E:\DBbackup\dailybuild.bck'
> WITH
> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> ,REPLACE
> GO|||> USE EAGLE
> GO
> RESTORE DATABASE EAGLE
Above will *not* work. You enter the eagle database yourself, and block the restore yourself. USE
master and then restore instead. Also, use ALTER DATABASE to se the database in single user mode,
having the ROLLBACK option to get rid of other users.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Mikus" <Mikus@.discussions.microsoft.com> wrote in message
news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
>I created script that would restore db automatically, but i have problem
> running ...
> i get error
> Server: Msg 3101, Level 16, State 1, Line 2
> Exclusive access could not be obtained because the database is in use.
> Server: Msg 3013, Level 16, State 1, Line 2
> RESTORE DATABASE is terminating abnormally.
> HOW do i modify this script to kill all users who use EAGLE database before
> restoring database ?
> USE EAGLE
> GO
> RESTORE DATABASE EAGLE
> FROM DISK = 'E:\DBbackup\dailybuild.bck'
> WITH
> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> ,REPLACE
> GO|||WHERE do i put ALTER DATABASE clause ?
this way ?
USE MASTER
GO
ALTER DATABASE
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
WITH
MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
,REPLACE
GO
"Tibor Karaszi" wrote:
> > USE EAGLE
> > GO
> >
> > RESTORE DATABASE EAGLE
> Above will *not* work. You enter the eagle database yourself, and block the restore yourself. USE
> master and then restore instead. Also, use ALTER DATABASE to se the database in single user mode,
> having the ROLLBACK option to get rid of other users.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
> >I created script that would restore db automatically, but i have problem
> > running ...
> > i get error
> >
> > Server: Msg 3101, Level 16, State 1, Line 2
> > Exclusive access could not be obtained because the database is in use.
> > Server: Msg 3013, Level 16, State 1, Line 2
> > RESTORE DATABASE is terminating abnormally.
> >
> > HOW do i modify this script to kill all users who use EAGLE database before
> > restoring database ?
> >
> > USE EAGLE
> > GO
> >
> > RESTORE DATABASE EAGLE
> > FROM DISK = 'E:\DBbackup\dailybuild.bck'
> > WITH
> > MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> > Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> > ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> > Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> > ,REPLACE
> > GO
>
>|||You need to read Books Online to see how to execute ALTER DATABASE (SINGLE USER, ROLBACK etc). But,
yes, you put it before your RESTORE command.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Mikus" <Mikus@.discussions.microsoft.com> wrote in message
news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
> WHERE do i put ALTER DATABASE clause ?
> this way ?
> USE MASTER
> GO
> ALTER DATABASE
> RESTORE DATABASE EAGLE
> FROM DISK = 'E:\DBbackup\dailybuild.bck'
> WITH
> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> ,REPLACE
> GO
> "Tibor Karaszi" wrote:
>> > USE EAGLE
>> > GO
>> >
>> > RESTORE DATABASE EAGLE
>> Above will *not* work. You enter the eagle database yourself, and block the restore yourself. USE
>> master and then restore instead. Also, use ALTER DATABASE to se the database in single user mode,
>> having the ROLLBACK option to get rid of other users.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>>
>> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
>> news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
>> >I created script that would restore db automatically, but i have problem
>> > running ...
>> > i get error
>> >
>> > Server: Msg 3101, Level 16, State 1, Line 2
>> > Exclusive access could not be obtained because the database is in use.
>> > Server: Msg 3013, Level 16, State 1, Line 2
>> > RESTORE DATABASE is terminating abnormally.
>> >
>> > HOW do i modify this script to kill all users who use EAGLE database before
>> > restoring database ?
>> >
>> > USE EAGLE
>> > GO
>> >
>> > RESTORE DATABASE EAGLE
>> > FROM DISK = 'E:\DBbackup\dailybuild.bck'
>> > WITH
>> > MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
>> > Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
>> > ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
>> > Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
>> > ,REPLACE
>> > GO
>>|||To automate the restore, I usually kill connected users then run the restore.
I have a stored procedure KillConn in master database which I always call
whenever I need to automate database restore. KillConn accepts a parameter
which is database name.
EXEC Master.dbo.KillConn 'Eagle'
go
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
...................................
Here is the extract of KillConn stored procedure:
CREATE PROCEDURE KillConn (@.db varchar(30))
AS
DECLARE @.ps VARCHAR(255)
DECLARE @.id smallint
DECLARE c CURSOR FOR
SELECT
DISTINCT
spid
FROM
master..sysprocesses
WHERE
dbid
IN
(SELECT
dbid
FROM
master..sysdatabases
WHERE
name
IN
(@.db))
OPEN c
FETCH NEXT FROM c INTO @.id
WHILE (@.@.FETCH_STATUS <> -1)
BEGIN
SELECT @.ps = 'KILL ' + CONVERT(VARCHAR(8), @.id)
EXEC(@.ps)
FETCH NEXT FROM c INTO @.id
END
CLOSE c
DEALLOCATE c
GO
"Tibor Karaszi" wrote:
> You need to read Books Online to see how to execute ALTER DATABASE (SINGLE USER, ROLBACK etc). But,
> yes, you put it before your RESTORE command.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
> > WHERE do i put ALTER DATABASE clause ?
> >
> > this way ?
> >
> > USE MASTER
> > GO
> >
> > ALTER DATABASE
> > RESTORE DATABASE EAGLE
> > FROM DISK = 'E:\DBbackup\dailybuild.bck'
> > WITH
> > MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> > Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> > ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> > Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> > ,REPLACE
> > GO
> >
> > "Tibor Karaszi" wrote:
> >
> >> > USE EAGLE
> >> > GO
> >> >
> >> > RESTORE DATABASE EAGLE
> >>
> >> Above will *not* work. You enter the eagle database yourself, and block the restore yourself. USE
> >> master and then restore instead. Also, use ALTER DATABASE to se the database in single user mode,
> >> having the ROLLBACK option to get rid of other users.
> >>
> >> --
> >> Tibor Karaszi, SQL Server MVP
> >> http://www.karaszi.com/sqlserver/default.asp
> >> http://www.solidqualitylearning.com/
> >>
> >>
> >> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> >> news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
> >> >I created script that would restore db automatically, but i have problem
> >> > running ...
> >> > i get error
> >> >
> >> > Server: Msg 3101, Level 16, State 1, Line 2
> >> > Exclusive access could not be obtained because the database is in use.
> >> > Server: Msg 3013, Level 16, State 1, Line 2
> >> > RESTORE DATABASE is terminating abnormally.
> >> >
> >> > HOW do i modify this script to kill all users who use EAGLE database before
> >> > restoring database ?
> >> >
> >> > USE EAGLE
> >> > GO
> >> >
> >> > RESTORE DATABASE EAGLE
> >> > FROM DISK = 'E:\DBbackup\dailybuild.bck'
> >> > WITH
> >> > MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> >> > Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> >> > ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> >> > Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> >> > ,REPLACE
> >> > GO
> >>
> >>
> >>
>
>|||This was not working ...
USE MASTER
GO
ALTER DATABASE EAGLE
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
WITH
MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
,REPLACE
GO
Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'RESTORE'.
i couldn't really find any info in server books online regarding SINGLE USER
MODE ?
"Tibor Karaszi" wrote:
> You need to read Books Online to see how to execute ALTER DATABASE (SINGLE USER, ROLBACK etc). But,
> yes, you put it before your RESTORE command.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
> > WHERE do i put ALTER DATABASE clause ?
> >
> > this way ?
> >
> > USE MASTER
> > GO
> >
> > ALTER DATABASE
> > RESTORE DATABASE EAGLE
> > FROM DISK = 'E:\DBbackup\dailybuild.bck'
> > WITH
> > MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> > Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> > ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> > Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> > ,REPLACE
> > GO
> >
> > "Tibor Karaszi" wrote:
> >
> >> > USE EAGLE
> >> > GO
> >> >
> >> > RESTORE DATABASE EAGLE
> >>
> >> Above will *not* work. You enter the eagle database yourself, and block the restore yourself. USE
> >> master and then restore instead. Also, use ALTER DATABASE to se the database in single user mode,
> >> having the ROLLBACK option to get rid of other users.
> >>
> >> --
> >> Tibor Karaszi, SQL Server MVP
> >> http://www.karaszi.com/sqlserver/default.asp
> >> http://www.solidqualitylearning.com/
> >>
> >>
> >> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> >> news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
> >> >I created script that would restore db automatically, but i have problem
> >> > running ...
> >> > i get error
> >> >
> >> > Server: Msg 3101, Level 16, State 1, Line 2
> >> > Exclusive access could not be obtained because the database is in use.
> >> > Server: Msg 3013, Level 16, State 1, Line 2
> >> > RESTORE DATABASE is terminating abnormally.
> >> >
> >> > HOW do i modify this script to kill all users who use EAGLE database before
> >> > restoring database ?
> >> >
> >> > USE EAGLE
> >> > GO
> >> >
> >> > RESTORE DATABASE EAGLE
> >> > FROM DISK = 'E:\DBbackup\dailybuild.bck'
> >> > WITH
> >> > MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> >> > Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> >> > ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> >> > Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> >> > ,REPLACE
> >> > GO
> >>
> >>
> >>
>
>|||Hi,
The exact command is:-
ALTER DATABASE EAGLE SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
Now issue the RESTORE database command. After the restore issue the below
command to make database multi user.
go
ALTER DATABASE EAGLE SET MULTI_USER
Thanks
Hari
SQL Server MVP
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:er0BvN6sFHA.2008@.TK2MSFTNGP10.phx.gbl...
> You need to read Books Online to see how to execute ALTER DATABASE (SINGLE
> USER, ROLBACK etc). But, yes, you put it before your RESTORE command.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
>> WHERE do i put ALTER DATABASE clause ?
>> this way ?
>> USE MASTER
>> GO
>> ALTER DATABASE
>> RESTORE DATABASE EAGLE
>> FROM DISK = 'E:\DBbackup\dailybuild.bck'
>> WITH
>> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
>> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
>> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
>> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
>> ,REPLACE
>> GO
>> "Tibor Karaszi" wrote:
>> > USE EAGLE
>> > GO
>> >
>> > RESTORE DATABASE EAGLE
>> Above will *not* work. You enter the eagle database yourself, and block
>> the restore yourself. USE
>> master and then restore instead. Also, use ALTER DATABASE to se the
>> database in single user mode,
>> having the ROLLBACK option to get rid of other users.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>>
>> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
>> news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
>> >I created script that would restore db automatically, but i have
>> >problem
>> > running ...
>> > i get error
>> >
>> > Server: Msg 3101, Level 16, State 1, Line 2
>> > Exclusive access could not be obtained because the database is in use.
>> > Server: Msg 3013, Level 16, State 1, Line 2
>> > RESTORE DATABASE is terminating abnormally.
>> >
>> > HOW do i modify this script to kill all users who use EAGLE database
>> > before
>> > restoring database ?
>> >
>> > USE EAGLE
>> > GO
>> >
>> > RESTORE DATABASE EAGLE
>> > FROM DISK = 'E:\DBbackup\dailybuild.bck'
>> > WITH
>> > MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
>> > Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
>> > ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
>> > Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
>> > ,REPLACE
>> > GO
>>
>|||Thanks a lot HAri
"Hari Prasad" wrote:
> Hi,
> The exact command is:-
> ALTER DATABASE EAGLE SET SINGLE_USER WITH ROLLBACK IMMEDIATE
> GO
> Now issue the RESTORE database command. After the restore issue the below
> command to make database multi user.
> go
> ALTER DATABASE EAGLE SET MULTI_USER
> Thanks
> Hari
> SQL Server MVP
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
> message news:er0BvN6sFHA.2008@.TK2MSFTNGP10.phx.gbl...
> > You need to read Books Online to see how to execute ALTER DATABASE (SINGLE
> > USER, ROLBACK etc). But, yes, you put it before your RESTORE command.
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > http://www.karaszi.com/sqlserver/default.asp
> > http://www.solidqualitylearning.com/
> >
> >
> > "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> > news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
> >> WHERE do i put ALTER DATABASE clause ?
> >>
> >> this way ?
> >>
> >> USE MASTER
> >> GO
> >>
> >> ALTER DATABASE
> >> RESTORE DATABASE EAGLE
> >> FROM DISK = 'E:\DBbackup\dailybuild.bck'
> >> WITH
> >> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> >> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> >> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> >> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> >> ,REPLACE
> >> GO
> >>
> >> "Tibor Karaszi" wrote:
> >>
> >> > USE EAGLE
> >> > GO
> >> >
> >> > RESTORE DATABASE EAGLE
> >>
> >> Above will *not* work. You enter the eagle database yourself, and block
> >> the restore yourself. USE
> >> master and then restore instead. Also, use ALTER DATABASE to se the
> >> database in single user mode,
> >> having the ROLLBACK option to get rid of other users.
> >>
> >> --
> >> Tibor Karaszi, SQL Server MVP
> >> http://www.karaszi.com/sqlserver/default.asp
> >> http://www.solidqualitylearning.com/
> >>
> >>
> >> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> >> news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
> >> >I created script that would restore db automatically, but i have
> >> >problem
> >> > running ...
> >> > i get error
> >> >
> >> > Server: Msg 3101, Level 16, State 1, Line 2
> >> > Exclusive access could not be obtained because the database is in use.
> >> > Server: Msg 3013, Level 16, State 1, Line 2
> >> > RESTORE DATABASE is terminating abnormally.
> >> >
> >> > HOW do i modify this script to kill all users who use EAGLE database
> >> > before
> >> > restoring database ?
> >> >
> >> > USE EAGLE
> >> > GO
> >> >
> >> > RESTORE DATABASE EAGLE
> >> > FROM DISK = 'E:\DBbackup\dailybuild.bck'
> >> > WITH
> >> > MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> >> > Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> >> > ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> >> > Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> >> > ,REPLACE
> >> > GO
> >>
> >>
> >>
> >
> >
>
>
running ...
i get error
Server: Msg 3101, Level 16, State 1, Line 2
Exclusive access could not be obtained because the database is in use.
Server: Msg 3013, Level 16, State 1, Line 2
RESTORE DATABASE is terminating abnormally.
HOW do i modify this script to kill all users who use EAGLE database before
restoring database ?
USE EAGLE
GO
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
WITH
MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
,REPLACE
GOMikus
Lookup SINGLE USER MODE in the BOL.
"Mikus" <Mikus@.discussions.microsoft.com> wrote in message
news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
>I created script that would restore db automatically, but i have problem
> running ...
> i get error
> Server: Msg 3101, Level 16, State 1, Line 2
> Exclusive access could not be obtained because the database is in use.
> Server: Msg 3013, Level 16, State 1, Line 2
> RESTORE DATABASE is terminating abnormally.
> HOW do i modify this script to kill all users who use EAGLE database
> before
> restoring database ?
> USE EAGLE
> GO
> RESTORE DATABASE EAGLE
> FROM DISK = 'E:\DBbackup\dailybuild.bck'
> WITH
> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> ,REPLACE
> GO|||> USE EAGLE
> GO
> RESTORE DATABASE EAGLE
Above will *not* work. You enter the eagle database yourself, and block the restore yourself. USE
master and then restore instead. Also, use ALTER DATABASE to se the database in single user mode,
having the ROLLBACK option to get rid of other users.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Mikus" <Mikus@.discussions.microsoft.com> wrote in message
news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
>I created script that would restore db automatically, but i have problem
> running ...
> i get error
> Server: Msg 3101, Level 16, State 1, Line 2
> Exclusive access could not be obtained because the database is in use.
> Server: Msg 3013, Level 16, State 1, Line 2
> RESTORE DATABASE is terminating abnormally.
> HOW do i modify this script to kill all users who use EAGLE database before
> restoring database ?
> USE EAGLE
> GO
> RESTORE DATABASE EAGLE
> FROM DISK = 'E:\DBbackup\dailybuild.bck'
> WITH
> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> ,REPLACE
> GO|||WHERE do i put ALTER DATABASE clause ?
this way ?
USE MASTER
GO
ALTER DATABASE
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
WITH
MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
,REPLACE
GO
"Tibor Karaszi" wrote:
> > USE EAGLE
> > GO
> >
> > RESTORE DATABASE EAGLE
> Above will *not* work. You enter the eagle database yourself, and block the restore yourself. USE
> master and then restore instead. Also, use ALTER DATABASE to se the database in single user mode,
> having the ROLLBACK option to get rid of other users.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
> >I created script that would restore db automatically, but i have problem
> > running ...
> > i get error
> >
> > Server: Msg 3101, Level 16, State 1, Line 2
> > Exclusive access could not be obtained because the database is in use.
> > Server: Msg 3013, Level 16, State 1, Line 2
> > RESTORE DATABASE is terminating abnormally.
> >
> > HOW do i modify this script to kill all users who use EAGLE database before
> > restoring database ?
> >
> > USE EAGLE
> > GO
> >
> > RESTORE DATABASE EAGLE
> > FROM DISK = 'E:\DBbackup\dailybuild.bck'
> > WITH
> > MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> > Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> > ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> > Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> > ,REPLACE
> > GO
>
>|||You need to read Books Online to see how to execute ALTER DATABASE (SINGLE USER, ROLBACK etc). But,
yes, you put it before your RESTORE command.
--
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
"Mikus" <Mikus@.discussions.microsoft.com> wrote in message
news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
> WHERE do i put ALTER DATABASE clause ?
> this way ?
> USE MASTER
> GO
> ALTER DATABASE
> RESTORE DATABASE EAGLE
> FROM DISK = 'E:\DBbackup\dailybuild.bck'
> WITH
> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> ,REPLACE
> GO
> "Tibor Karaszi" wrote:
>> > USE EAGLE
>> > GO
>> >
>> > RESTORE DATABASE EAGLE
>> Above will *not* work. You enter the eagle database yourself, and block the restore yourself. USE
>> master and then restore instead. Also, use ALTER DATABASE to se the database in single user mode,
>> having the ROLLBACK option to get rid of other users.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>>
>> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
>> news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
>> >I created script that would restore db automatically, but i have problem
>> > running ...
>> > i get error
>> >
>> > Server: Msg 3101, Level 16, State 1, Line 2
>> > Exclusive access could not be obtained because the database is in use.
>> > Server: Msg 3013, Level 16, State 1, Line 2
>> > RESTORE DATABASE is terminating abnormally.
>> >
>> > HOW do i modify this script to kill all users who use EAGLE database before
>> > restoring database ?
>> >
>> > USE EAGLE
>> > GO
>> >
>> > RESTORE DATABASE EAGLE
>> > FROM DISK = 'E:\DBbackup\dailybuild.bck'
>> > WITH
>> > MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
>> > Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
>> > ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
>> > Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
>> > ,REPLACE
>> > GO
>>|||To automate the restore, I usually kill connected users then run the restore.
I have a stored procedure KillConn in master database which I always call
whenever I need to automate database restore. KillConn accepts a parameter
which is database name.
EXEC Master.dbo.KillConn 'Eagle'
go
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
...................................
Here is the extract of KillConn stored procedure:
CREATE PROCEDURE KillConn (@.db varchar(30))
AS
DECLARE @.ps VARCHAR(255)
DECLARE @.id smallint
DECLARE c CURSOR FOR
SELECT
DISTINCT
spid
FROM
master..sysprocesses
WHERE
dbid
IN
(SELECT
dbid
FROM
master..sysdatabases
WHERE
name
IN
(@.db))
OPEN c
FETCH NEXT FROM c INTO @.id
WHILE (@.@.FETCH_STATUS <> -1)
BEGIN
SELECT @.ps = 'KILL ' + CONVERT(VARCHAR(8), @.id)
EXEC(@.ps)
FETCH NEXT FROM c INTO @.id
END
CLOSE c
DEALLOCATE c
GO
"Tibor Karaszi" wrote:
> You need to read Books Online to see how to execute ALTER DATABASE (SINGLE USER, ROLBACK etc). But,
> yes, you put it before your RESTORE command.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
> > WHERE do i put ALTER DATABASE clause ?
> >
> > this way ?
> >
> > USE MASTER
> > GO
> >
> > ALTER DATABASE
> > RESTORE DATABASE EAGLE
> > FROM DISK = 'E:\DBbackup\dailybuild.bck'
> > WITH
> > MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> > Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> > ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> > Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> > ,REPLACE
> > GO
> >
> > "Tibor Karaszi" wrote:
> >
> >> > USE EAGLE
> >> > GO
> >> >
> >> > RESTORE DATABASE EAGLE
> >>
> >> Above will *not* work. You enter the eagle database yourself, and block the restore yourself. USE
> >> master and then restore instead. Also, use ALTER DATABASE to se the database in single user mode,
> >> having the ROLLBACK option to get rid of other users.
> >>
> >> --
> >> Tibor Karaszi, SQL Server MVP
> >> http://www.karaszi.com/sqlserver/default.asp
> >> http://www.solidqualitylearning.com/
> >>
> >>
> >> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> >> news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
> >> >I created script that would restore db automatically, but i have problem
> >> > running ...
> >> > i get error
> >> >
> >> > Server: Msg 3101, Level 16, State 1, Line 2
> >> > Exclusive access could not be obtained because the database is in use.
> >> > Server: Msg 3013, Level 16, State 1, Line 2
> >> > RESTORE DATABASE is terminating abnormally.
> >> >
> >> > HOW do i modify this script to kill all users who use EAGLE database before
> >> > restoring database ?
> >> >
> >> > USE EAGLE
> >> > GO
> >> >
> >> > RESTORE DATABASE EAGLE
> >> > FROM DISK = 'E:\DBbackup\dailybuild.bck'
> >> > WITH
> >> > MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> >> > Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> >> > ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> >> > Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> >> > ,REPLACE
> >> > GO
> >>
> >>
> >>
>
>|||This was not working ...
USE MASTER
GO
ALTER DATABASE EAGLE
RESTORE DATABASE EAGLE
FROM DISK = 'E:\DBbackup\dailybuild.bck'
WITH
MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
,REPLACE
GO
Server: Msg 156, Level 15, State 1, Line 3
Incorrect syntax near the keyword 'RESTORE'.
i couldn't really find any info in server books online regarding SINGLE USER
MODE ?
"Tibor Karaszi" wrote:
> You need to read Books Online to see how to execute ALTER DATABASE (SINGLE USER, ROLBACK etc). But,
> yes, you put it before your RESTORE command.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
> > WHERE do i put ALTER DATABASE clause ?
> >
> > this way ?
> >
> > USE MASTER
> > GO
> >
> > ALTER DATABASE
> > RESTORE DATABASE EAGLE
> > FROM DISK = 'E:\DBbackup\dailybuild.bck'
> > WITH
> > MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> > Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> > ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> > Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> > ,REPLACE
> > GO
> >
> > "Tibor Karaszi" wrote:
> >
> >> > USE EAGLE
> >> > GO
> >> >
> >> > RESTORE DATABASE EAGLE
> >>
> >> Above will *not* work. You enter the eagle database yourself, and block the restore yourself. USE
> >> master and then restore instead. Also, use ALTER DATABASE to se the database in single user mode,
> >> having the ROLLBACK option to get rid of other users.
> >>
> >> --
> >> Tibor Karaszi, SQL Server MVP
> >> http://www.karaszi.com/sqlserver/default.asp
> >> http://www.solidqualitylearning.com/
> >>
> >>
> >> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> >> news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
> >> >I created script that would restore db automatically, but i have problem
> >> > running ...
> >> > i get error
> >> >
> >> > Server: Msg 3101, Level 16, State 1, Line 2
> >> > Exclusive access could not be obtained because the database is in use.
> >> > Server: Msg 3013, Level 16, State 1, Line 2
> >> > RESTORE DATABASE is terminating abnormally.
> >> >
> >> > HOW do i modify this script to kill all users who use EAGLE database before
> >> > restoring database ?
> >> >
> >> > USE EAGLE
> >> > GO
> >> >
> >> > RESTORE DATABASE EAGLE
> >> > FROM DISK = 'E:\DBbackup\dailybuild.bck'
> >> > WITH
> >> > MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> >> > Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> >> > ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> >> > Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> >> > ,REPLACE
> >> > GO
> >>
> >>
> >>
>
>|||Hi,
The exact command is:-
ALTER DATABASE EAGLE SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
Now issue the RESTORE database command. After the restore issue the below
command to make database multi user.
go
ALTER DATABASE EAGLE SET MULTI_USER
Thanks
Hari
SQL Server MVP
"Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
message news:er0BvN6sFHA.2008@.TK2MSFTNGP10.phx.gbl...
> You need to read Books Online to see how to execute ALTER DATABASE (SINGLE
> USER, ROLBACK etc). But, yes, you put it before your RESTORE command.
> --
> Tibor Karaszi, SQL Server MVP
> http://www.karaszi.com/sqlserver/default.asp
> http://www.solidqualitylearning.com/
>
> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
>> WHERE do i put ALTER DATABASE clause ?
>> this way ?
>> USE MASTER
>> GO
>> ALTER DATABASE
>> RESTORE DATABASE EAGLE
>> FROM DISK = 'E:\DBbackup\dailybuild.bck'
>> WITH
>> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
>> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
>> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
>> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
>> ,REPLACE
>> GO
>> "Tibor Karaszi" wrote:
>> > USE EAGLE
>> > GO
>> >
>> > RESTORE DATABASE EAGLE
>> Above will *not* work. You enter the eagle database yourself, and block
>> the restore yourself. USE
>> master and then restore instead. Also, use ALTER DATABASE to se the
>> database in single user mode,
>> having the ROLLBACK option to get rid of other users.
>> --
>> Tibor Karaszi, SQL Server MVP
>> http://www.karaszi.com/sqlserver/default.asp
>> http://www.solidqualitylearning.com/
>>
>> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
>> news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
>> >I created script that would restore db automatically, but i have
>> >problem
>> > running ...
>> > i get error
>> >
>> > Server: Msg 3101, Level 16, State 1, Line 2
>> > Exclusive access could not be obtained because the database is in use.
>> > Server: Msg 3013, Level 16, State 1, Line 2
>> > RESTORE DATABASE is terminating abnormally.
>> >
>> > HOW do i modify this script to kill all users who use EAGLE database
>> > before
>> > restoring database ?
>> >
>> > USE EAGLE
>> > GO
>> >
>> > RESTORE DATABASE EAGLE
>> > FROM DISK = 'E:\DBbackup\dailybuild.bck'
>> > WITH
>> > MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
>> > Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
>> > ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
>> > Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
>> > ,REPLACE
>> > GO
>>
>|||Thanks a lot HAri
"Hari Prasad" wrote:
> Hi,
> The exact command is:-
> ALTER DATABASE EAGLE SET SINGLE_USER WITH ROLLBACK IMMEDIATE
> GO
> Now issue the RESTORE database command. After the restore issue the below
> command to make database multi user.
> go
> ALTER DATABASE EAGLE SET MULTI_USER
> Thanks
> Hari
> SQL Server MVP
> "Tibor Karaszi" <tibor_please.no.email_karaszi@.hotmail.nomail.com> wrote in
> message news:er0BvN6sFHA.2008@.TK2MSFTNGP10.phx.gbl...
> > You need to read Books Online to see how to execute ALTER DATABASE (SINGLE
> > USER, ROLBACK etc). But, yes, you put it before your RESTORE command.
> >
> > --
> > Tibor Karaszi, SQL Server MVP
> > http://www.karaszi.com/sqlserver/default.asp
> > http://www.solidqualitylearning.com/
> >
> >
> > "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> > news:D1E93E36-8892-4BBF-92AA-71AEA28489AE@.microsoft.com...
> >> WHERE do i put ALTER DATABASE clause ?
> >>
> >> this way ?
> >>
> >> USE MASTER
> >> GO
> >>
> >> ALTER DATABASE
> >> RESTORE DATABASE EAGLE
> >> FROM DISK = 'E:\DBbackup\dailybuild.bck'
> >> WITH
> >> MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> >> Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> >> ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> >> Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> >> ,REPLACE
> >> GO
> >>
> >> "Tibor Karaszi" wrote:
> >>
> >> > USE EAGLE
> >> > GO
> >> >
> >> > RESTORE DATABASE EAGLE
> >>
> >> Above will *not* work. You enter the eagle database yourself, and block
> >> the restore yourself. USE
> >> master and then restore instead. Also, use ALTER DATABASE to se the
> >> database in single user mode,
> >> having the ROLLBACK option to get rid of other users.
> >>
> >> --
> >> Tibor Karaszi, SQL Server MVP
> >> http://www.karaszi.com/sqlserver/default.asp
> >> http://www.solidqualitylearning.com/
> >>
> >>
> >> "Mikus" <Mikus@.discussions.microsoft.com> wrote in message
> >> news:0DEE2C96-ADC1-4DEA-96EB-203E563D9028@.microsoft.com...
> >> >I created script that would restore db automatically, but i have
> >> >problem
> >> > running ...
> >> > i get error
> >> >
> >> > Server: Msg 3101, Level 16, State 1, Line 2
> >> > Exclusive access could not be obtained because the database is in use.
> >> > Server: Msg 3013, Level 16, State 1, Line 2
> >> > RESTORE DATABASE is terminating abnormally.
> >> >
> >> > HOW do i modify this script to kill all users who use EAGLE database
> >> > before
> >> > restoring database ?
> >> >
> >> > USE EAGLE
> >> > GO
> >> >
> >> > RESTORE DATABASE EAGLE
> >> > FROM DISK = 'E:\DBbackup\dailybuild.bck'
> >> > WITH
> >> > MOVE 'EAGLE_Data' TO 'C:\Program Files\Microsoft SQL
> >> > Server\MSSQL$TEST\Data\EAGLE_Data.MDF'
> >> > ,MOVE 'EAGLE_Log' TO 'C:\Program Files\Microsoft SQL
> >> > Server\MSSQL$TEST\Data\EAGLE_Log.LDF'
> >> > ,REPLACE
> >> > GO
> >>
> >>
> >>
> >
> >
>
>
Friday, March 9, 2012
Restore and update problem on Windows
Hi,
I have restored a database from a BAK file and tried to run a update query.
While executing the query , i got this error.
Server: Msg 208, Level 16, State 1, Procedure ctsv_992F1918D5FC11D4968C0090271F4533, Line 2
Invalid object name 'MSmerge_contents'.
What can be the possible reasons for the error?
Suggest the solutions if any.Which version of sql server are you using ? Are you using merge replication ?|||Hi,
I am using the MS SQL Server 2000.
About merge replication, i am not aware of this as i am a new user. More over we are restoring the backup that we have, from the restored database we can see all this views and procedures which are used for merge replication.
How can we check that we are using merge replication?
Regards,|||Look under enterprise manager - go to the replication folder - look at publications or subscriptions and you should see entries.|||Are you restoring onto the same sql server instance ? Are you only restoring a particular database ?|||Hi,
There are no entries in the Publications and Subscriptions folder.
We are restoring a particular backup that we got from our client.|||Are you saying then that this is not a backup of the current machine you are working with - it was a backup of another sql server machine ? Or are you restoring on the clients machine ?|||Hi,
Yes , you guessed that correctly.
It's a backup from some other machine (client's db backup) and we are restoring it on our machine for fixing few things.
This original database is not with us and we do not have details of his machine either. We only have the .BAK file.|||Without that information, you are running in the fog. My only recommendation is to try and run sp_mergecleanupmetadata - make sure you read the bol about this stored procedure. The only problem is that you have no replication so this stored procedure may be of no use. Let me know if you have any success with this.
When you say you are fixing a few things - will these fixes go back to the client ?
I have restored a database from a BAK file and tried to run a update query.
While executing the query , i got this error.
Server: Msg 208, Level 16, State 1, Procedure ctsv_992F1918D5FC11D4968C0090271F4533, Line 2
Invalid object name 'MSmerge_contents'.
What can be the possible reasons for the error?
Suggest the solutions if any.Which version of sql server are you using ? Are you using merge replication ?|||Hi,
I am using the MS SQL Server 2000.
About merge replication, i am not aware of this as i am a new user. More over we are restoring the backup that we have, from the restored database we can see all this views and procedures which are used for merge replication.
How can we check that we are using merge replication?
Regards,|||Look under enterprise manager - go to the replication folder - look at publications or subscriptions and you should see entries.|||Are you restoring onto the same sql server instance ? Are you only restoring a particular database ?|||Hi,
There are no entries in the Publications and Subscriptions folder.
We are restoring a particular backup that we got from our client.|||Are you saying then that this is not a backup of the current machine you are working with - it was a backup of another sql server machine ? Or are you restoring on the clients machine ?|||Hi,
Yes , you guessed that correctly.
It's a backup from some other machine (client's db backup) and we are restoring it on our machine for fixing few things.
This original database is not with us and we do not have details of his machine either. We only have the .BAK file.|||Without that information, you are running in the fog. My only recommendation is to try and run sp_mergecleanupmetadata - make sure you read the bol about this stored procedure. The only problem is that you have no replication so this stored procedure may be of no use. Let me know if you have any success with this.
When you say you are fixing a few things - will these fixes go back to the client ?
Wednesday, March 7, 2012
Restore a DB
I am trying to restore a DB from a BackUp File
but I get the foll msg..
Any suggestions ? Thanks in advance.
Server: Msg 3132, Level 16, State 1, Line 1
The media set for database 'AAD_GSA' has 2 family members
but only 1 are provided. All members must be provided.
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.i think you have backed up the database on more than one backup devices.
Therefore you will have to specify all the devices that you have specified
at the time of backup to perform restore operation successfully.
see following example
--create 2 backup devices
use master
go
sp_addumpdevice 'disk', 'mydiskdump','c:\northwind.bak'
go
sp_addumpdevice 'disk','mydiskdump1', 'c:\northwind1.bak'
go
--backup database on both of them
backup database northwind to mydiskdump,mydiskdump1
--if you try to restore from one device it will give you for the restore
statement as follows.
restore database Northwind from mydiskdump
--you will have to specify both the devices at the time of backup.
restore database Northwind from mydiskdump, mydiskdump1
--
-Vishal
"ABonik" <ABONEIK@.hotmail.com> wrote in message
news:027a01c37174$4fd8a910$a101280a@.phx.gbl...
> I am trying to restore a DB from a BackUp File
> but I get the foll msg..
> Any suggestions ? Thanks in advance.
> Server: Msg 3132, Level 16, State 1, Line 1
> The media set for database 'AAD_GSA' has 2 family members
> but only 1 are provided. All members must be provided.
> Server: Msg 3013, Level 16, State 1, Line 1
> RESTORE DATABASE is terminating abnormally.|||perhaps you did a backup to 2 backup devices; when you restore you specify
only 1 device?
"ABonik" <ABONEIK@.hotmail.com> wrote in message
news:027a01c37174$4fd8a910$a101280a@.phx.gbl...
> I am trying to restore a DB from a BackUp File
> but I get the foll msg..
> Any suggestions ? Thanks in advance.
> Server: Msg 3132, Level 16, State 1, Line 1
> The media set for database 'AAD_GSA' has 2 family members
> but only 1 are provided. All members must be provided.
> Server: Msg 3013, Level 16, State 1, Line 1
> RESTORE DATABASE is terminating abnormally.
but I get the foll msg..
Any suggestions ? Thanks in advance.
Server: Msg 3132, Level 16, State 1, Line 1
The media set for database 'AAD_GSA' has 2 family members
but only 1 are provided. All members must be provided.
Server: Msg 3013, Level 16, State 1, Line 1
RESTORE DATABASE is terminating abnormally.i think you have backed up the database on more than one backup devices.
Therefore you will have to specify all the devices that you have specified
at the time of backup to perform restore operation successfully.
see following example
--create 2 backup devices
use master
go
sp_addumpdevice 'disk', 'mydiskdump','c:\northwind.bak'
go
sp_addumpdevice 'disk','mydiskdump1', 'c:\northwind1.bak'
go
--backup database on both of them
backup database northwind to mydiskdump,mydiskdump1
--if you try to restore from one device it will give you for the restore
statement as follows.
restore database Northwind from mydiskdump
--you will have to specify both the devices at the time of backup.
restore database Northwind from mydiskdump, mydiskdump1
--
-Vishal
"ABonik" <ABONEIK@.hotmail.com> wrote in message
news:027a01c37174$4fd8a910$a101280a@.phx.gbl...
> I am trying to restore a DB from a BackUp File
> but I get the foll msg..
> Any suggestions ? Thanks in advance.
> Server: Msg 3132, Level 16, State 1, Line 1
> The media set for database 'AAD_GSA' has 2 family members
> but only 1 are provided. All members must be provided.
> Server: Msg 3013, Level 16, State 1, Line 1
> RESTORE DATABASE is terminating abnormally.|||perhaps you did a backup to 2 backup devices; when you restore you specify
only 1 device?
"ABonik" <ABONEIK@.hotmail.com> wrote in message
news:027a01c37174$4fd8a910$a101280a@.phx.gbl...
> I am trying to restore a DB from a BackUp File
> but I get the foll msg..
> Any suggestions ? Thanks in advance.
> Server: Msg 3132, Level 16, State 1, Line 1
> The media set for database 'AAD_GSA' has 2 family members
> but only 1 are provided. All members must be provided.
> Server: Msg 3013, Level 16, State 1, Line 1
> RESTORE DATABASE is terminating abnormally.
Subscribe to:
Posts (Atom)