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.
SELECT CASE SERVERPROPERTY('IsSingleUser')
WHEN 0 THEN 'No'
WHEN 1 THEN 'Yes'
END as [Is SQL Server in single-user mode]