mannaggia (2/15/2011)
I just do this:
ALTER DATABASE dbname
SET SINGLE_USER WITH ROLLBACK IMMEDIATE
GO
ALTER DATABASE dbname
SET MULTI_USER
GO
Any advantage or disadvantage over the script?
I guess it depends on the conext of the situation, but I'd generally reccomend RESTRICTED_USER (allowing any SYSADMIN to connect multiple times) over SINGLE_USER, which allows ANY user to grab the next connection exclusively.
"Do not seek to follow in the footsteps of the wise. Instead, seek what they sought." - Matsuo Basho