Hello Guys..!
Some times while restoring Ax database we get below error.
Error: Restore failed for Server 'ServerName\InstanceName'. System.Data.SqlClient.SqlError: Exclusive access could not be obtained because the database is in use.
Reason : Ax Database is using by some service.
Solution : Kill all active connections which are using Ax database
Change the database name in the query and execute .
DECLARE @dbname NVARCHAR(128)
SET @dbname = 'DB name here'
-- db to drop connections
DECLARE @processid INT
SELECT @processid = MIN(spid)
FROM master.dbo.sysprocesses
WHERE dbid = DB_ID(@dbname)
WHILE @processid IS NOT NULL
BEGIN
EXEC ('KILL ' + @processid)
SELECT @processid = MIN(spid)
FROM master.dbo.sysprocesses
WHERE dbid = DB_ID(@dbname)
END
That's It...
@Rahul Talasila
Some times while restoring Ax database we get below error.
Error: Restore failed for Server 'ServerName\InstanceName'. System.Data.SqlClient.SqlError: Exclusive access could not be obtained because the database is in use.
Reason : Ax Database is using by some service.
Solution : Kill all active connections which are using Ax database
Change the database name in the query and execute .
DECLARE @dbname NVARCHAR(128)
SET @dbname = 'DB name here'
-- db to drop connections
DECLARE @processid INT
SELECT @processid = MIN(spid)
FROM master.dbo.sysprocesses
WHERE dbid = DB_ID(@dbname)
WHILE @processid IS NOT NULL
BEGIN
EXEC ('KILL ' + @processid)
SELECT @processid = MIN(spid)
FROM master.dbo.sysprocesses
WHERE dbid = DB_ID(@dbname)
END
That's It...
@Rahul Talasila
No comments:
Post a Comment