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

No comments:

Post a Comment

 
span.fullpost {display:inline;}