tags:

views:

19

answers:

1

Hello.

How test if the DB is in single user mode in a sql script?

Thanks.

Eduardo

+1  A: 

You can check the sys.databases view:

if (select user_access_desc from sys.databases where name = 'YourDb') = 'SINGLE_USER'
    begin
    print 'It''s in single user!'
    end
Andomar