if (SELECT user_access_desc FROM sys.databases WHERE name = 'YourDb') = 'SINGLE_USER' begin print 'It is in single user mode!' end