IdleTymes Blog

Personal Diary, Musing and rubish of a F*!^%#g bored programmer.

This is how to remove users from databases using TSQL. First you must find out what the stored procedure sp_who to find out who is on the system and what their spid is. Query Analyzer:

USE [Database name]

Execute sp_who

this will the list everyone who is on the database along with the spid, it give you some details like login name, it’s status and the command that it is processing from theis you should be able to figure out who is causign problems. Bear in mind that you don’t want to just kill anyone out because that could cause so real problems in the database. Best bet to be careful is try not to kill anything that is owned by the database owner.

then type:

kill [spid]

If you are attempting to detach a database, then it is best to do it through Enterprise Manager because it know exactly which processes are preventing the database from shutting down.


Comments are closed.