Sometimes when you try to restore the AX database, it will be converted into a Single User mode. And it will now allow you to perform any task against the AX database.
To rectify that, please try to execute the below query.
ALTER DATABASE AXDB SET MULTI_USER WITH ROLLBACK IMMEDIATE
If you have any deadlock on the database, you will receive the below error.
To rectify this issue, we need to kill the dependent process on the database. To identify the process please use the below sql script.
- Get the database id
(select dbid from sysdatabases where [name] =’AxDB’)
- Find all the process on the database id
select spID from sysprocesses where dbid IN 5
Once, you find the spID of the process, you should kill the process by using below code
Kill <spID>
Now execute alter table to change the database to multi user mode using below query.
ALTER DATABASE AXDB SET MULTI_USER WITH ROLLBACK IMMEDIATE
Alternatively, you can use the below script to find lock processes
SELECT * FROM sys.dm_tran_locks WHERE resource_database_id = DB_ID(‘AxDB’)
And kill the process with the request_session_id as shown below code
kill 53
kill 51
ALTER DATABASE AXDB SET MULTI_USER WITH ROLLBACK IMMEDIATE