2012年3月19日星期一

Disconnect a particular session

How do I disconnect a particular session without having to stop and restart
the server? I read the article on the DISCONNECT statement in BOL but it
takes as an argument a name, not a connection number. How do I know the
'name' of the connection? Is there a system stored proc that will do this,
taking a connection number as an argument?
Check out KILL in the BOL.
Tom
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql
"Ron Hinds" <__NoSpam@.__NoSpamramac.com> wrote in message
news:eWSxgYHjEHA.1656@.TK2MSFTNGP09.phx.gbl...
How do I disconnect a particular session without having to stop and restart
the server? I read the article on the DISCONNECT statement in BOL but it
takes as an argument a name, not a connection number. How do I know the
'name' of the connection? Is there a system stored proc that will do this,
taking a connection number as an argument?
|||A session in SQL Server is represented by a Server Process ID (SPID).
To get your current spid, invoke the @.@.SPID function.
To figure out others' spids, query master..sysprocesses or run sp_who or
sp_who2.
To terminate a connection use KILL <spid>.
To terminate your own session, you can raise an error with severity 20 (only
if you are a sysadmin), e.g.,
RAISERROR ('Connection Seppuku', 20, 1) WITH LOG
BG, SQL Server MVP
www.SolidQualityLearning.com
"Ron Hinds" <__NoSpam@.__NoSpamramac.com> wrote in message
news:eWSxgYHjEHA.1656@.TK2MSFTNGP09.phx.gbl...
> How do I disconnect a particular session without having to stop and
restart
> the server? I read the article on the DISCONNECT statement in BOL but it
> takes as an argument a name, not a connection number. How do I know the
> 'name' of the connection? Is there a system stored proc that will do this,
> taking a connection number as an argument?
>
|||Thanks guys!
"Itzik Ben-Gan" <itzik@.REMOVETHIS.SolidQualityLearning.com> wrote in message
news:u0cYFmHjEHA.3536@.TK2MSFTNGP12.phx.gbl...
> A session in SQL Server is represented by a Server Process ID (SPID).
> To get your current spid, invoke the @.@.SPID function.
> To figure out others' spids, query master..sysprocesses or run sp_who or
> sp_who2.
> To terminate a connection use KILL <spid>.
> To terminate your own session, you can raise an error with severity 20
(only[vbcol=seagreen]
> if you are a sysadmin), e.g.,
> RAISERROR ('Connection Seppuku', 20, 1) WITH LOG
> --
> BG, SQL Server MVP
> www.SolidQualityLearning.com
>
> "Ron Hinds" <__NoSpam@.__NoSpamramac.com> wrote in message
> news:eWSxgYHjEHA.1656@.TK2MSFTNGP09.phx.gbl...
> restart
this,
>

没有评论:

发表评论