I want to use a script to detach mulitple databases, starting with the name eqs.
I have found a script to use that should have the functions i need for this. Although this script does not work "standalone" without removing the "print" before each command.
I was hoping for help to do this without the "print" commands, running the script, and make it work :)
Does anyone know what changes i can make to this script to make it work?
And is it possible to run this script from a Powershell script or something like that?
set nocount on
declare @dbname as varchar(80)
declare @server_name as varchar(20)
select @server_name = @@servername
declare rs_cursor CURSOR for select name from master.dbo.sysdatabases where name like ('eqs%') AND name not in ('eqs_test', 'eqs_log')
Fetch next from rs_cursor into @dbname
IF @@FETCH_STATUS <> 0
PRINT 'No database to backup...Please check your script!!!'
WHILE @@FETCH_STATUS = 0
print 'sp_detach_db' + @dbname
print 'print ''Detach of ' + upper(@dbname) + ' database successfully completed'''
PRINT ' '
FETCH NEXT FROM rs_cursor INTO @dbname
print ' '
print 'print ''SERVER NAME : ' + upper(@server_name) + '--> All databases successfully detached'''