/*
This script is a bit more tricky to edit so I'll leave my examples,
but basically leave the ' 
and seperate your sources with ,

remove my example sources and add your device ones.
*/


DELETE FROM [ION_Data].[dbo].[Channel]
WHERE [RecorderID] IN (SELECT [ID] FROM [ION_Data].[dbo].[Recorder] 
WHERE [SourceID] IN (SELECT [ID] FROM [ION_Data].[dbo].[Source] 
WHERE [Name] IN (
'Sanimex.1008_001_WtrMtr_M11',
'Sanimex.1008_001_WtrMtr_M12',
'Sanimex.1008_001_WtrMtr_M17',
'Sanimex.1008_001_WtrMtr_M2',
'Sanimex.1008_001_WtrMtr_M24',
'Sanimex.1008_001_WtrMtr_M25',
'Sanimex.1008_001_WtrMtr_M4',
'Sanimex.1008_001_WtrMtr_M5',
'Sanimex.1008_001_WtrMtr_M7',
'Sanimex.1008_001_WtrMtr_M9_2'
)))
 
DELETE FROM [ION_Data].[dbo].[RecorderState]
WHERE [RecorderID] IN (SELECT [ID] FROM [ION_Data].[dbo].[Recorder]
WHERE [SourceID] IN (SELECT [ID] FROM [ION_Data].[dbo].[Source]
WHERE [Name] IN (
'Sanimex.1008_001_WtrMtr_M11',
'Sanimex.1008_001_WtrMtr_M12',
'Sanimex.1008_001_WtrMtr_M17',
'Sanimex.1008_001_WtrMtr_M2',
'Sanimex.1008_001_WtrMtr_M24',
'Sanimex.1008_001_WtrMtr_M25',
'Sanimex.1008_001_WtrMtr_M4',
'Sanimex.1008_001_WtrMtr_M5',
'Sanimex.1008_001_WtrMtr_M7',
'Sanimex.1008_001_WtrMtr_M9_2'
)))
 
DELETE FROM [ION_Data].[dbo].[Recorder]
WHERE [ID] IN (SELECT [ID] FROM [ION_Data].[dbo].[Recorder]
WHERE [SourceID] IN (SELECT [ID] FROM [ION_Data].[dbo].[Source]
WHERE [Name] IN (
'Sanimex.1008_001_WtrMtr_M11',
'Sanimex.1008_001_WtrMtr_M12',
'Sanimex.1008_001_WtrMtr_M17',
'Sanimex.1008_001_WtrMtr_M2',
'Sanimex.1008_001_WtrMtr_M24',
'Sanimex.1008_001_WtrMtr_M25',
'Sanimex.1008_001_WtrMtr_M4',
'Sanimex.1008_001_WtrMtr_M5',
'Sanimex.1008_001_WtrMtr_M7',
'Sanimex.1008_001_WtrMtr_M9_2'
)))
 
DELETE FROM [ION_Network].[dbo].[IAS_MeasurementAddress]
WHERE [SourceID] IN (SELECT [SourceID] FROM [ION_Network].[dbo].[SRC_Source]
WHERE [Name] IN (
'Sanimex.1008_001_WtrMtr_M11',
'Sanimex.1008_001_WtrMtr_M12',
'Sanimex.1008_001_WtrMtr_M17',
'Sanimex.1008_001_WtrMtr_M2',
'Sanimex.1008_001_WtrMtr_M24',
'Sanimex.1008_001_WtrMtr_M25',
'Sanimex.1008_001_WtrMtr_M4',
'Sanimex.1008_001_WtrMtr_M5',
'Sanimex.1008_001_WtrMtr_M7',
'Sanimex.1008_001_WtrMtr_M9_2'
))