SQL Enterprise Manager reports 'no items'

Run this script in query analyzer against the master db

===================copy everything below this line=====================

USE master

GO

DECLARE @db_name varchar(500)



DECLARE dbn_cursor CURSOR FOR

SELECT [name] FROM sysdatabases;



OPEN dbn_cursor



FETCH NEXT FROM dbn_cursor

INTO @db_name



WHILE @@FETCH_STATUS = 0

BEGIN

select * from sysdatabases where name = @db_name

IF @@ERROR <> 0

BEGIN

declare @off int

print 'Restarting database '+@db_name

  

exec @off = sp_dboption @db_name, 'offline', 'TRUE'

IF @off <> 0 

print 'Taking offline failed! Need manual workaround!'

else

begin

declare @on int

exec @on = sp_dboption @db_name, 'offline', 'FALSE'     

IF @on <> 0
'Bringing online failed! Need manual workaround!' 

else

print 'Restart successfull!'

end 

END

FETCH NEXT FROM dbn_cursor

INTO @db_name

END


CLOSE dbn_cursor

DEALLOCATE dbn_cursor

GO

 

===================copy everything above=====================

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

Connection Strings

We're often asked how to create a connection string to a database.  In fact a variety of...

How do I Publish my Microsoft SQL server database

In order to publish your database to your hosting package, you need to use the SQL database...

SQL Object Ownership script

DECLARE @objname nvarchar(517),@DynSQL nvarchar(4000) DECLARE obj_cursor CURSOR FORSELECT name...

SQL db shrink code

--Select Count(name) from sysdatabases declare @db as varchar(100)set @db = 'db to be shrunk...

Why can't I connect to the SQL server using Enterprise Manager/Management Studio

SQL Enterprise Manager tries, by default, to connect via Named Pipes. As this cannot run across...