Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
harshal_in
Aged Yak Warrior
633 Posts |
Posted - 2003-02-11 : 00:43:01
|
| hi,I want to kill all the processes in the database to drop that specific database I am using the following script:declare @spid intdeclare kill_cursor cursor for (select spid from sysprocesses where dbid in (select dbid from sysdatabases where name='database_name'))open kill_cursor fetch next from kill_cursor into@spidwhile @@fetch_status =0begin kill @spidprint @spidfetch next from kill_cursorinto @spidendclose kill_cursordeallocate kill_cursorgobut it gives me error at the kill statement.any ideas would be highly appreciated.Regards,Harshal.Expect the UnExpected |
|
|
srf
Starting Member
42 Posts |
Posted - 2003-02-11 : 14:31:39
|
| Looks like you need to wrap it in an exec. Example:declare @SPID intdeclare @sqlString varchar(255)select @SPID = 54select @sqlString = 'kill ' + convert(varchar, @SPID)exec (@sqlString) |
 |
|
|
|
|
|