Thursday, April 9, 2009

Disconnect all users from SQL Database

Run the code below on SQL Management Studio,

DECLARE @User VARCHAR(8000)
SELECT @user=COALESCE(@user,'')+'Kill '+CAST(spid AS VARCHAR(10))+ '; '
FROM sys.sysprocesses WHERE DBID=DB_ID('EF_GR') EXEC(@user)

//EF_GR is a name of database

1 comment:

  1. Hi, it's a very great blog.
    I could tell how much efforts you've taken on it.
    Keep doing!

    ReplyDelete

 
span.fullpost {display:inline;}