Question : sp_detach_db

Hi,
i need to detach database using osql, even if it's in use.
when detaching database from EM, window appears with option to clear current connection.
how can this be done using T-sql?

Answer : sp_detach_db

You could also do it as follows

alter database set single_user with rollback immediate

<....... do your stuff here ..........>
-- also make sure to issue a "use master" before calling sp_detach

alter database set multi_user with rollback immediate
Random Solutions  
 
programming4us programming4us