Finding and Killing Sessions in Sybase

The first step in killing a session in a Sybase database is to find the session to kill. Connect to Sybase as a user that has the privileges necessary to run queries to find sessions and execute commands to kill sessions. The following query will list running sessions in a Sybase database:

SELECT * FROM master.dbo.sysprocesses p, master.dbo.syslogins l, master.dbo.sysdatabases d, master.dbo.sysprocesses p2 WHERE p.suid *= l.suid AND p.dbid *= d.dbid AND p.spid *= p2.blocked ORDER BY p.spid;

One of the columns returned from the above query is the spid. The value of this column is what is needed to kill a session. After determining the spid of the session to be killed, execute the following command to kill the session. In this example, the spid is 19.

kill 19;