Generate script to put Sql Server databases offline

Say you are migrating databases from one server to another. You don’t want users connect to the old instance by mistake. You can do that by putting them all offline. Below is the script t

set nocount on
select ‘alter database ‘ + name + ‘ set offline’ from sysdatabases where
name not in (‘master’, ‘msdb’, ‘model’, ‘tempdb’)


Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.