DBA- Generate Script To Bring All User Databases Online in SQL Server

The below query can be used to generate scripts to bring SQL Server Databases from Offline state to Online.

SELECT 'ALTER DATABASE ['+name+'] SET ONLINE'+CHAR(10)+' GO' 
FROM MASTER.sys.databases
WHERE name NOT IN ('master','tempdb','model','msdb','distribution')
AND state_desc='OFFLINE'

3 comments:

  1. Great Article it its really informative and innovative keep us posted with new updates. its was really valuable. thanks a lot. Free Generator

    ReplyDelete
  2. This is wonderful and quite informative website design agencies blog I have learnt so many things from here.

    ReplyDelete