I've got a SQL query that is trying to update threshold information on a SolarWinds database.
The main data is within the Nodes view and the Thresholds table contains the warning and critical threshold limits. I INNER JOIN these and attach them via the Thresholds.InstanceID and Nodes.NodeID data columns.
This query will update thresholds IF custom thresholds have already been set; however when you add a new device into SolarWinds it uses the default threshold values and doesn't add them into the Thresholds table.
USE SolarWindsOrionGOUPDATE ThresholdsSET Warning = 20, Critical = 25FROM ThresholdsINNER JOIN dbo.Nodes N ON InstanceId = NodeIDWHERE N.Environment = 'Test' AND N.DeviceRole = 'Database'
How do I get this query to first check if the NodeID is in the InstanceID column and if not add a new row and reference the NodeID and add the custom Warning and Critical values?