Files
DP44/DataPRO/Modules/Database/DatabaseMigrationScripts/.svn/pristine/44/445dfc9dff3e09b12c9ed79c9f6786c2f961059d.svn-base

23 lines
1.3 KiB
Plaintext
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
CREATE PROCEDURE [dbo].[sp_SensorsUARTGet]
@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.BaudRate, B.DataBits, B.StopBits, B.Parity, B.FlowControl, B.DataFormat, B.LastModified, B.LastModifiedBy, B.UserTags, B.Broken, B.DoNotUse FROM [dbo].[Sensors] AS A INNER JOIN [dbo].[SensorsUART] AS B ON A.id=B.SensorId INNER JOIN [dbo].SensorsType AS C ON A.SensorType=C.TypeId WHERE C.SensorType='UART'
END
ELSE
BEGIN
SELECT A.id, A.SerialNumber, B.BaudRate, B.DataBits, B.StopBits, B.Parity, B.FlowControl, B.DataFormat, B.LastModified, B.LastModifiedBy, B.UserTags, B.Broken, B.DoNotUse FROM [dbo].[Sensors] AS A INNER JOIN [dbo].[SensorsUART] AS B ON A.id=B.SensorId INNER JOIN [dbo].SensorsType AS C ON A.SensorType=C.TypeId WHERE C.SensorType='UART' AND A.SerialNumber=@SerialNumber
END
END
ELSE
BEGIN
SELECT A.id, A.SerialNumber, B.BaudRate, B.DataBits, B.StopBits, B.Parity, B.FlowControl, B.DataFormat, B.LastModified, B.LastModifiedBy, B.UserTags, B.Broken, B.DoNotUse FROM [dbo].[Sensors] AS A INNER JOIN [dbo].[SensorsUART] AS B ON A.id=B.SensorId INNER JOIN [dbo].SensorsType AS C ON A.SensorType=C.TypeId WHERE C.SensorType='UART' AND A.id=@Id
END
END