Skip to main content

Posts

Showing posts with the label SQL Db

SQL DB Stuck during Take Offline

Dear All, If your database Take offline process has stuck then don't worry just follow the below steps and you will make your database offline: Steps 1) Run the following command EXEC sp_who2 2) List down the SPID # run again your database column (DBNAME) 3) kill the process... 4) Once you kill all the processes then run the following command ALTER DATABASE [myDB] SET OFFLINE WITH ROLLBACK IMMEDIATE After that your datbase goes offline, now  you will make a copy for it There is another process if you have many process runing to gather you can use below query DECLARE @DatabaseName nvarchar(50) SET @DatabaseName = N'Write your database name' DECLARE @SQL varchar(max) SET @SQL = '' SELECT @SQL = @SQL + 'Kill ' + Convert(varchar, SPId) + ';' FROM MASTER..SysProcesses WHERE DBId = DB_ID(@DatabaseName) AND SPId <> @@SPId EXEC(@SQL) ALTER DATABASE [Write your database name] SET OFFLINE WITH ROLLBACK IMMEDIATE GO Regard...