SMS SQL for Count of Status Messages

The following SQL query returns a count of status messages by year, month, day, hour. The dateadd function subtracts 3 days from todays date, giving us counts for the last 3 days.

----Begin SQL----

--Count of Status Messages Broken Down by Year, Month, Day, Hour
Select Datepart(yy,time), Datepart(mm,time), Datepart(dd,time), Datepart(hh,time), Count(*)
FROM StatusMessages
Where Time > dateadd(dd, -3, getdate())
Group By Datepart(yy,time), Datepart(mm,time), Datepart(dd,time), Datepart(hh,time)

----End SQL----

About the Author

Emmanuel Tsouris is a Systems Management veteran and Developer Advocate specializing in PowerShell and Cloud Automation. He maintains DotVBS to preserve legacy knowledge for the "archaeologist admin."

Ready to move from VBScript to the Cloud? Check out his book, Pro PowerShell for Amazon Web Services.

Visit EmmanuelTsouris.com for his latest projects.

As an Amazon Associate, I earn from qualifying purchases at no cost to you.

Comments

Popular posts from this blog

SMS "Program failed (run time exceeded)" 10070

SMS "Waiting for User Condition" 10036

Reading the SCCM Client GUID