23 lines
1.2 KiB
Plaintext
23 lines
1.2 KiB
Plaintext
|
|
CREATE PROCEDURE [dbo].[sp_SensorsThermocouplerGet]
|
||
|
|
@Id INT = null,
|
||
|
|
@SerialNumber NVARCHAR (50) = null
|
||
|
|
AS
|
||
|
|
BEGIN
|
||
|
|
SET NOCOUNT ON;
|
||
|
|
|
||
|
|
IF( @Id IS NULL)
|
||
|
|
BEGIN
|
||
|
|
IF NULLIF(@SerialNumber, '') IS NULL
|
||
|
|
BEGIN
|
||
|
|
SELECT A.id, A.SerialNumber, B.LastModified, B.LastModifiedBy, B.UserTags, B.Broken, B.DoNotUse FROM [dbo].[Sensors] AS A INNER JOIN [dbo].[SensorsThermocoupler] AS B ON A.id=B.SensorId INNER JOIN [dbo].SensorsType AS C ON A.SensorType=C.TypeId WHERE C.SensorType='Thermocoupler'
|
||
|
|
END
|
||
|
|
ELSE
|
||
|
|
BEGIN
|
||
|
|
SELECT A.id, A.SerialNumber, B.LastModified, B.LastModifiedBy, B.UserTags, B.Broken, B.DoNotUse FROM [dbo].[Sensors] AS A INNER JOIN [dbo].[SensorsThermocoupler] AS B ON A.id=B.SensorId INNER JOIN [dbo].SensorsType AS C ON A.SensorType=C.TypeId WHERE C.SensorType='Thermocoupler' AND A.SerialNumber=@SerialNumber
|
||
|
|
END
|
||
|
|
END
|
||
|
|
ELSE
|
||
|
|
BEGIN
|
||
|
|
SELECT A.id, A.SerialNumber, B.LastModified, B.LastModifiedBy, B.UserTags, B.Broken, B.DoNotUse FROM [dbo].[Sensors] AS A INNER JOIN [dbo].[SensorsThermocoupler] AS B ON A.id=B.SensorId INNER JOIN [dbo].SensorsType AS C ON A.SensorType=C.TypeId WHERE C.SensorType='Thermocoupler' AND A.id=@Id
|
||
|
|
END
|
||
|
|
END
|