Files
DP44/DataPRO_sql/dbo.sp_TestObjectSensorsGet.StoredProcedure.sql
2026-04-17 14:55:32 -04:00

50 lines
3.1 KiB
Transact-SQL
Raw Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
IF EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sp_TestObjectSensorsGet]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[sp_TestObjectSensorsGet]
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_TestObjectSensorsGet]') AND type in (N'P', N'PC'))
BEGIN
EXEC dbo.sp_executesql @statement = N'CREATE PROCEDURE [dbo].[sp_TestObjectSensorsGet] AS'
END
GO
ALTER PROCEDURE [dbo].[sp_TestObjectSensorsGet]
@TestObjectName nvarchar(255) = null
AS
BEGIN
declare @TestObjectId int
set @TestObjectId = dbo.foo_IdGetTestObject(@TestObjectName)
SET NOCOUNT ON;
select
tob.TestObjectName + '_' + convert(varchar(1), tos.ISOChannel) + '_' + convert(varchar(5), tos.ISOChannelId) as [UIChannelID]
, s.SerialNumber as [SensorId]
,isnull([ZoneId], space(0)) as [ZoneId]
,tos.DASId as [DasId]
,tos.[ChannelId] as [DasChannelId]
,tos.[ChannelIdx] as [ChannelIdx]
from [dbo].[TestObjectSensors] tos
inner join [dbo].[TestObjects] tob on tob.TestObjectId = tos.TestObjectId
inner join [dbo].[v_SensorSerialNumber] s on s.SensorId = tos.SensorId
where @TestObjectName is null or tos.TestObjectId = @TestObjectId
END
GO