Skip to content

Instantly share code, notes, and snippets.

@danesparza
Created February 24, 2017 19:20
Show Gist options
  • Save danesparza/f6260ef3a496e5341b213f1f52214d01 to your computer and use it in GitHub Desktop.
Save danesparza/f6260ef3a496e5341b213f1f52214d01 to your computer and use it in GitHub Desktop.
SQL server script to get the error count by hour for the logging database
select
'Year' = DATEPART(YEAR, log_date),
'Month' = DATEPART(MONTH, log_date),
'Day' = DATEPART(DAY, log_date),
'Hour' = DATEPART(HOUR, log_date),
'Entries' = count(*)
from
system_logging
where
log_level = 'Error'
GROUP BY
DATEPART(YEAR, log_date),
DATEPART(MONTH, log_date),
DATEPART(DAY, log_date),
DATEPART(HOUR, log_date)
order by
DATEPART(YEAR, log_date),
DATEPART(MONTH, log_date),
DATEPART(DAY, log_date),
DATEPART(HOUR, log_date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment