Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2004
    Posts
    7

    Unanswered: Pls Help!!!!! How to disconnect uses from database

    Hi,

    Please help!! I need to load a database. For that I need to disconnect all users from database. Which commands should I use to find out which users are using that database & then to disconnect them?
    We use Sybase 12.5 ASE.


    Thanks!!!

  2. #2
    Join Date
    Mar 2003
    Posts
    23

    Re: Pls Help!!!!! How to disconnect uses from database

    Originally posted by Syb125User9
    Hi,

    Please help!! I need to load a database. For that I need to disconnect all users from database. Which commands should I use to find out which users are using that database & then to disconnect them?
    We use Sybase 12.5 ASE.


    Thanks!!!
    Hope this helps
    select b.name,a.spid,a.ipaddr,a.loggedindatetime from master..sysprocesses a, master..sysdatabases b
    where a.dbid= (select db_id()) and a.dbid = b.dbid

    then you can kill the spid or ask the user to logoff. Also check for detached transactions using sp_transactions.

  3. #3
    Join Date
    Nov 2002
    Location
    Switzerland
    Posts
    524
    The following select will return you the lines to execute, killing the necessary users.

    Code:
    select "kill "+convert(varchar(5),spid)
    from master..sysprocesses
    where dbid= db_id("YourDB")
    Since v.12, you can improve that, generating a sp that do that automatically, using the Dynamic SQL with exec.

  4. #4
    Join Date
    Jan 2004
    Posts
    7
    Thanks guys!

    Both methods work!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •