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 |
|
rj_khatri
Starting Member
13 Posts |
Posted - 2003-07-19 : 01:58:39
|
| Dear Friends,Hi!!Is there any command to kill all the running user processes in one runor do i need to get the process id one by one and then kill.ThanksRajesh Khatri |
|
|
harshal_in
Aged Yak Warrior
633 Posts |
Posted - 2003-07-19 : 03:58:54
|
quote: Dear Friends,Hi!!Is there any command to kill all the running user processes in one runor do i need to get the process id one by one and then kill.ThanksRajesh Khatri
U can use KILL to kill all the runnung processess,this can be done one by one only ,u can write a stored procedure to automate it.The Judgement of the Judge is as good as the Judge. |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2003-07-21 : 10:33:13
|
| ALTER DATABASE [dbname] SET SINGLE_USER WITH ROLLBACK IMMEDIATEBrett8-) |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2003-07-21 : 12:34:42
|
| declare @Doomeduserid varchar(3)While exists(select * from master..sysprocesses where db_name(dbid) = 'DBNameGoesHere' and spid <> @@spid) Begin SELECT @Doomeduserid = convert (varchar(3),(select max(spid) from sysprocesses where db_name(dbid) = 'DBNameGoesHere' and spid <> @@spid)) exec ("kill " +@Doomeduserid ) ENDThe above worked for SQL 7.0. I have not used it for 2000, but it will probably work. Why do you want to kill all of the processes anyway though? If it is because you are going to restore the database, then just run the code that Brett posted. But if you just want everybody out and not change the database state, then try the above code.Tara |
 |
|
|
|
|
|