SQL 7 - Set Single_User

  • I try to use sp_dboption to set single _user in SQL 7 but can't, due to the fact that an application keeps getting back to the db when I kill the process. What should I do?

    Please HELP... Thank you!

  • hi, can you temporarily remove the logins permissions in the database in question ?

    or change the default database to another one ? this may make the connection fail, so you can change the option. However don't forget to undo the changes after you've finished

    Paul.

  • I usually try something like this "kill & set" in an attempt to get the single_user option in before the other user/app does:

     
    
    use master
    declare @kill varchar (8000)
    select @kill = ISNULL(@kill , '') + ' kill ' + cast(spid as varchar)
    from sysprocesses where dbid = db_id('pubs')
    print @kill
    exec (@kill)
    exec sp_dboption 'pubs', 'single', true

    Cheers,

    - Mark


    Cheers,
    - Mark

  • Thank you very much, guys, for the input.

    Mark, your script worked great. I wonder if you could help me understand the following line. What does ISNULL(@kill , '') do in the statement? Thanks again.

    select @kill = ISNULL(@kill , '') + ' kill ' + cast(spid as varchar) from sysprocesses where dbid = db_id('pubs')

  • The ISNULL(@kill , '') will replace the null value in @kill with a single space, this is needed because anything plus a null value results in a null.

    jimmY

    Work like you don't need the money.

    Love like you've never been hurt.

    And Dance like no one is watching.


    Work like you don't need the money.
    Love like you've never been hurt.
    And Dance like no one is watching.

  • Thank you for the explaination, Jimmy.

  • Thanks Jimmy.

    Time zone sometimes prevent a prompt reply.

    Cheers,

    - Mark


    Cheers,
    - Mark

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply