Created
September 6, 2014 12:49
-
-
Save lski/6d12520a6089fc77bff7 to your computer and use it in GitHub Desktop.
Bring all offline databases back online TSQL 2000
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DECLARE @name VARCHAR(50) -- database name | |
DECLARE db_cursor CURSOR FOR | |
SELECT name | |
FROM master.dbo.sysdatabases | |
where DATABASEPROPERTYEX(name, 'Status') = 'OFFLINE' | |
ORDER BY 1 | |
OPEN db_cursor | |
FETCH NEXT FROM db_cursor INTO @name | |
WHILE @@FETCH_STATUS = 0 | |
BEGIN | |
-- Take the Database Online | |
EXEC ('ALTER DATABASE ' + @name + ' SET ONLINE;'); | |
FETCH NEXT FROM db_cursor INTO @name | |
END | |
CLOSE db_cursor | |
DEALLOCATE db_cursor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment