I am using the CASE command to simply change a substring query result from a number to a name.
Things seem to work fine but I am having a hard time trying to figure out why the results only display the first value of the string.
Declare @OverrideON INT, @OverrideOFF INT
SET @OverrideON = 1 SET @OverrideOFF = 0
SELECT LonDeviceName,
CASE WHEN SUBSTRING (PointValue,65,1) = @OverrideON THEN 'Fan In Override'
WHEN SUBSTRING (PointValue,67,1) = @OverrideON THEN 'HW In Override'
WHEN SUBSTRING (PointValue,69,1) = @OverrideON THEN 'CHW In Override'
WHEN SUBSTRING (PointValue,71,1) = @OverrideON THEN 'OAD In Override'
WHEN SUBSTRING (PointValue,73,1) = @OverrideON THEN 'VFD In Override'
WHEN SUBSTRING (PointValue,65,1) = @OverrideOFF THEN 'Fan Normal'
WHEN SUBSTRING (PointValue,67,1) = @OverrideOFF THEN 'HW Normal'
WHEN SUBSTRING (PointValue,69,1) = @OverrideOFF THEN 'CHW Normal'
WHEN SUBSTRING (PointValue,71,1) = @OverrideOFF THEN 'OAD Normal'
WHEN SUBSTRING (PointValue,73,1) = @OverrideOFF THEN 'VFD Normal'
ELSE '**StringError**'
END as 'Manual Overrides'
FROM dbo.Points
WHERE LogicName like '%override%'
When the code is run it creates a column titled Manual Overrides which is correct, in that column it displays the first value within the string. But, where are the results for the other four values within the string. Any assistance or ideas would be greatly appreciated.
Thanks.
How about something like this: