Thursday, March 29, 2012

getting the list of sessions

Hi,
I would like to get the list of connections/sessions from the server. Here
is the information that I wanted to retrieve.
Database Name
OS Username (from client)
Machine Name (client)
Type of Connection
Username (database)
Time of connection (used to filter output)
Is it possible to retrive using single SQL statement.
Thanks,
Ramutry following SP:
sp_who2
--
Ekrem Ã?nsoy
"Ramu" <Ramu@.discussions.microsoft.com> wrote in message
news:42ADB51C-4F38-4EBD-8E07-92557DBAA210@.microsoft.com...
> Hi,
> I would like to get the list of connections/sessions from the server. Here
> is the information that I wanted to retrieve.
> Database Name
> OS Username (from client)
> Machine Name (client)
> Type of Connection
> Username (database)
> Time of connection (used to filter output)
>
> Is it possible to retrive using single SQL statement.
> Thanks,
> Ramu|||Is it possible to issue select statement on sp_who2?
"Ekrem Ã?nsoy" wrote:
> try following SP:
> sp_who2
> --
> Ekrem Ã?nsoy
>
> "Ramu" <Ramu@.discussions.microsoft.com> wrote in message
> news:42ADB51C-4F38-4EBD-8E07-92557DBAA210@.microsoft.com...
> > Hi,
> >
> > I would like to get the list of connections/sessions from the server. Here
> > is the information that I wanted to retrieve.
> >
> > Database Name
> > OS Username (from client)
> > Machine Name (client)
> > Type of Connection
> > Username (database)
> > Time of connection (used to filter output)
> >
> >
> > Is it possible to retrive using single SQL statement.
> >
> > Thanks,
> > Ramu
>|||> Is it possible to issue select statement on sp_who2?
Not directly, but you can create a #temp table first, and insert into the
#temp table, then select from the #temp table.
http://databases.aspfaq.com/database/should-i-use-a-temp-table-or-a-table-variable.html
Or, if you are using SQL Server 2005, you can create your own version of
sp_who2...
http://sqlserver2005.databases.aspfaq.com/better-sp-who2.html
http://sqlserver2005.databases.aspfaq.com/how-do-i-mimic-sp-who2.html|||Doesn't <SELECT * FROM master..sysprocesses> give you that info?
Linchi
"Ramu" wrote:
> Hi,
> I would like to get the list of connections/sessions from the server. Here
> is the information that I wanted to retrieve.
> Database Name
> OS Username (from client)
> Machine Name (client)
> Type of Connection
> Username (database)
> Time of connection (used to filter output)
>
> Is it possible to retrive using single SQL statement.
> Thanks,
> Ramu

No comments:

Post a Comment