IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_DBImportTestSetupGraphs]') AND type in (N'P', N'PC')) DROP PROCEDURE [dbo].[sp_DBImportTestSetupGraphs] GO SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO IF NOT EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_DBImportTestSetupGraphs]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_DBImportTestSetupGraphs] AS' END GO ALTER PROCEDURE [dbo].[sp_DBImportTestSetupGraphs] @TestSetupId int ,@Graphs xml AS BEGIN insert into [dbo].[TestGraphs] ([TestSetupId] ,[GraphName] ,[GraphDescription] ,[Channels] ,[UseDomainMin] ,[DomainMin] ,[UseDomainMax] ,[DomainMax] ,[UseRangeMin] ,[RangeMin] ,[UseRangeMax] ,[RangeMax] ,[Thresholds] ,[LocalOnly]) select @TestSetupId , t.x.value('(./GraphName)[1]', 'nvarchar(50)') , t.x.value('(./GraphDescription)[1]', 'nvarchar(50)') , t.x.value('(./Channels)[1]', 'nvarchar(2048)') , t.x.value('(./UseDomainMin)[1]', 'bit') , t.x.value('(./DomainMin)[1]', 'float') , t.x.value('(./UseDomainMax)[1]', 'bit') , t.x.value('(./DomainMax)[1]', 'float') , t.x.value('(./UseRangeMin)[1]', 'bit') , t.x.value('(./RangeMin)[1]', 'float') , t.x.value('(./UseRangeMax)[1]', 'bit') , t.x.value('(./RangeMax)[1]', 'float') , t.x.value('(./Thresholds)[1]', 'nvarchar(2048)') , t.x.value('(./LocalOnly)[1]', 'bit') from @Graphs.nodes('/Graphs/Graph') t(x) END GO