I would like to know how (and by extension if it's possible) to put SQL Server 2005 in single user mode using SQL statements?
I found these instructions on the MSDN, but alas they require SSMS.
http://msdn.microsoft.com/en-us/library/ms345598(SQL.90,loband).aspx
*To set a database to single-user mode
- In Object Explorer, connect to an instance of the SQL Server 2005 Database Engine, and then expand that instance.
- Right-click the database to change, and then click Properties.
- In the Database Properties dialog box, click the Options page.
- From the Restrict Access option, select Single.
- If other users are connected to the database, an Open Connections message will appear. To change the property and close all other connections, click Yes.*