This discussion has been locked. The information referenced herein may be inaccurate due to age, software updates, or external references.
You can no longer post new replies to this discussion. If you have a similar question you can start a new discussion in this forum.

convert SQL to SWQL

Can any one helpme convert below sql query to SWQL. Basically this query give output in chart for custom time period.(exclude daily maintenance period 01.00am to 03.00am)

DECLARE @StartDate DATETIME, @EndDate DATETIME

SET @StartDate = dateadd(mm, -1, getdate())

SET @StartDate = dateadd(dd, datepart(dd, getdate())*-1, @StartDate)

SET @EndDate = dateadd(mm, 1, @StartDate)

SELECT  TOP 999999999 Convert(DateTime,Floor(Cast((DateTime) as Float)*24)/24,0) AS SummaryDateTime,

Nodes.Caption AS NodeName,

Nodes.IP_Address AS IP_Address,

AVG(CPULoad.AvgLoad) AS AVERAGE_of_AvgCPULoad,

Nodes.NodeID AS NodeID

FROM

Nodes INNER JOIN CPULoad ON (Nodes.NodeID = CPULoad.NodeID)

WHERE

( DateTime BETWEEN @startDate AND @EndDate )

AND

Nodes.caption = '${caption}'

AND

CONVERT(varchar, DateTime,108) BETWEEN '03:00:00' AND '12:59:00'

)

GROUP BY Convert(DateTime,Floor(Cast((DateTime) as Float)*24)/24,0),

Nodes.Caption, Nodes.IP_Address, Nodes.NodeID

ORDER BY SummaryDateTime ASC

  • Well - could just give you the query - or...teach you how to go figure it out. 

    First thing - go download the SolarWinds Orion SDK.    It has SWQL Studio with it.

    Make a connection to your core server (easiest way) -- NOT the SQL server!   Once you have a working SQL query, then paste it in there, and you can do table look ups to determine the names you need on the tables.   It is helpful if you alias your table names in the "from" line, so it is easier to deal with.

    see more here Convert SQL query to SWQL