Clear all connections to a Micrsoft SQL Server(MSSQL)

By Nisse Pettersson at February 17, 2010 04:32
Filed Under: Technical
Share on Facebook

Sometimes you need to clear allt he connections to the database in order to make som changes to it. I guess that there is a lot of way doing this but this one suites me.

USE master;
GO
ALTER DATABASE [databaseName]
SET SINGLE_USER
WITH ROLLBACK IMMEDIATE;
GO
ALTER DATABASE [databaseName]
SET MULTI_USER;
GO

 

Found it on this site



Add comment




  Country flag

biuquote
  • Comment
  • Preview
Loading