IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_DASChannelsGet]') AND type in (N'P', N'PC')) DROP PROCEDURE [dbo].[sp_DASChannelsGet] 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_DASChannelsGet]') AND type in (N'P', N'PC')) BEGIN EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_DASChannelsGet] AS' END GO ALTER PROCEDURE [dbo].[sp_DASChannelsGet] @HardwareId nvarchar(50) = null AS BEGIN SET NOCOUNT ON; SELECT d.[SerialNumber] + '_' + convert(varchar(2), d.[Type]) as HardwareId ,dc.[ChannelIdx] ,dc.[SupportedBridges] ,dc.[SupportedExcitations] ,dc.[DASDisplayOrder] ,dc.[LocalOnly] ,dc.[SupportedDigitalInputModes] ,dc.[SupportedSquibFireModes] ,dc.[SupportedDigitalOutputModes] ,dc.[ModuleSerialNumber] ,dc.[ModuleArrayIndex] from [dbo].[DASChannels] dc inner join [dbo].[DAS] d on dc.DASId = d.DASId where @HardwareId is null or dc.[DASId] = dbo.foo_IdGetDAS(@HardwareId) END GO