Wednesday, March 7, 2012

Check a user is connected to the database or not

Can any one tell me the way to know whether a given user id is
logged into the sql server or connected to any database or not? I want to
remove a user if he is not logged into the server or not connected to any
database.
Can any one give me the T-Sql statement which solves my problem?
Thanks in advance.
VenkatEXEC sp_who 'LoginName' '
Francesco Anti
"Venkat" <tammana@.inooga.com> wrote in message
news:O72%23AandFHA.612@.TK2MSFTNGP12.phx.gbl...
> Can any one tell me the way to know whether a given user id is
> logged into the sql server or connected to any database or not? I want to
> remove a user if he is not logged into the server or not connected to any
> database.
>
> Can any one give me the T-Sql statement which solves my
> problem?
>
> Thanks in advance.
>
> --
> Venkat
>
>|||Hi,
You can use SP_WHO and sp_dropuser and sp_droplogin system stored
procedures.
Thanks
Hari
SQL Server MVP
"Venkat" <tammana@.inooga.com> wrote in message
news:O72%23AandFHA.612@.TK2MSFTNGP12.phx.gbl...
> Can any one tell me the way to know whether a given user id is
> logged into the sql server or connected to any database or not? I want to
> remove a user if he is not logged into the server or not connected to any
> database.
>
> Can any one give me the T-Sql statement which solves my
> problem?
>
> Thanks in advance.
>
> --
> Venkat
>
>

No comments:

Post a Comment