Tuesday, January 31, 2017

TO MONITOR THE SQL DB Connection & Statistics ( Azure & On-Premises)

Usually when you want to understand the SQL Usage, it is also better to look at the number of connections SQL Server has made to get an understanding of what kind connection is being made and from how long users are connected to the SQL DB/Instance.

We can use the below simple Queries  to identify the number of connections the SQL Instance is running at that moment.


USE MASTER
GO

SELECT
      E.CONNECTION_ID,
      S.SESSION_ID,
      S.LOGIN_NAME,
      S.LAST_REQUEST_END_TIME,
      S.CPU_TIME
FROM
      SYS.DM_EXEC_SESSIONS S
      INNER JOIN SYS.DM_EXEC_CONNECTIONS E
      ON S.SESSION_ID = E.SESSION_ID
GO


USE THE BELOW QUERY TO RUN IT ON AZURE SQL TO OBTAIN THE CONNECTION STATISTICS


We can use the below mentioned query to obtain connection Statistics on SQL Azure.


SELECT * FROM SYS.DATABASE_CONNECTION_STATS
WHERE DATABASE_NAME = '<DATABASENAME>' AND START_TIME > '<TIMESTAMP>' --Provide Time in this format '2014-06-12 00:00:00.0000000'
ORDER BY START_TIME DESC

No comments:

Post a Comment

Multiple Linear Regression

Multiple Linear Regression is a process that uses multiple explanatory variables to predict the outcome of a response variable . The pu...