Home Forums SQL Server 2005 Administering Changing Database In Single User Mode To Multi User RE: Changing Database In Single User Mode To Multi User

  • Some one is connected that db...

    Do you any monitoring tools connecting to this db...

    What is the error you are getting...when you try change it to multi user mode?

     

    Try the following script...

     

    DECLARE @ID INT

    DECLARE @MSG CHAR(8), @DataName sysname

    While 1 = 1

    BEGIN

        Set RowCount 1

     SELECT

      @id = spid

     FROM

      Master..Sysprocesses P,

      Master..Sysdatabases D

     WHERE

      <A href="mailto.Name=@DataName">D.Name=@DataName 

     AND

      D.dbid = P.dbid

        IF @@rowcount = 0

        break

        SELECT @msg = 'KILL ' + convert(char(8) ,@ID) 

        Print @msg

        EXEC( @msg)

        --break

    END

    GO

    ALTER DATABASE....

    GO

     

     

    MohammedU
    Microsoft SQL Server MVP