How to get detailed list of connections to database in sql server 2005?
相关问题
- sql execution latency when assign to a variable
- What is the best way to cache a table from a (SQL)
- php PDO::FETCH_ASSOC doesnt detect select after ba
- Bulk update SQL Server C#
- NOT DISTINCT query in mySQL
相关文章
- Entity Framework 4.3.1 failing to create (/open) a
- Code for inserting data into SQL Server database u
- Connection pooling vs persist connection mysqli
- Delete Every Alternate Row in SQL
- Linux based PHP install connecting to MsSQL Server
- SQL Azure Reset autoincrement
- How do we alias a Sql Server instance name used in
- Is recursion good in SQL Server?
Use the system stored procedure
sp_who2
.sp_who2 will actually provide a list of connections for the database server, not a database. To view connections for a single database (YourDatabaseName in this example), you can use
(Adapted from SQL Server: Filter output of sp_who2.)
As @Hutch pointed out, one of the major limitations of
sp_who2
is that it does not take any parameters so you cannot sort or filter it by default. You can save the results into a temp table, but then the you have to declare all the types ahead of time (and remember toDROP TABLE
).Instead, you can just go directly to the source on
master.dbo.sysprocesses
I've constructed this to output almost exactly the same thing that
sp_who2
generates, except that you can easily addORDER BY
andWHERE
clauses to get meaningful output.There is also who is active?: