Sometimes SQL developers want to put some logic into their T-Sql code to check whether SQL Server running is in single-user mode . The SERVERPROPERTY() built in metadata system function can be used to identify the single-user mode. SERVERPROPERTY() function with IsSingleUser Property will return “0” for Not single user mode and “1” for Single user mode.
1 2 3 4 5 6 7 8 |
USE [master]; GO SELECT CASE SERVERPROPERTY('IsSingleUser') WHEN 0 THEN 'No' WHEN 1 THEN 'Yes' ELSE 'Unknown' END as [Is SQL Server in single-user mode] |
Leave a Comment