Sqlserver
 sql >> Database >  >> RDS >> Sqlserver

trova il numero di connessione aperta sul database

Questo mostra il numero di connessioni per ogni DB:

SELECT 
    DB_NAME(dbid) as DBName, 
    COUNT(dbid) as NoOfConnections,
    loginame as LoginName
FROM
    sys.sysprocesses
WHERE 
    dbid > 0
GROUP BY 
    dbid, loginame

E questo dà connessioni totali:

SELECT 
    COUNT(dbid) as TotalConnections
FROM
    sys.sysprocesses
WHERE 
    dbid > 0

Da c#, puoi seguire:
http:// www.c-sharpcorner.com/UploadFile/dsdaf/ConnPooling07262006093645AM/ConnPooling.aspx Un altro buon riferimento può essere trovato su:
http://www.wduffy.co.uk/blog/monitoring-database-connections/">http:// www.wduffy.co.uk/blog/monitoring-database-connections/

Chiama il metodo statico ReleaseObjectPool su OleDbConnection - vedere http://msdn.microsoft. .com/en-us/library/system.data.oledb.oledbconnection.releaseobjectpool.aspx