Here is what I do to ensure that I get the ONE (1) connection for SINGLE_USER.
USE MyDB; -- Use the database you want to make SINGLE_USERGOALTER DATABASE MyDB SET SINGLE_USER WITH ROLLBACK IMMEDIATE;GORESTORE DATABASE ----; /* Or whatever you need to do. */GOALTER DATABASE MyDB SET MULTI_USER;GO
The trick is to be in the database already when you switch to SINGLE_USER mode. This way, you are the SINGLE_USER and nobody else can get in until you return the database to MULTI_USER.
NOTE: If you exit the database while in SINGLE_USER mode someone else can take over the database. This can also cause you problems.