Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8288805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:21:16+00:00 2026-06-08T12:21:16+00:00

I am using the CASE command to simply change a substring query result from

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T12:21:19+00:00Added an answer on June 8, 2026 at 12:21 pm

    How about something like this:

    SELECT LonDeviceName,
        CASE  WHEN SUBSTRING (PointValue,65,1) = @OverrideON  THEN 'In Override'
              WHEN SUBSTRING (PointValue,65,1) = @OverrideOFF THEN 'Normal'
              ELSE '**StringError**'
        END as 'Fan',
        CASE  WHEN SUBSTRING (PointValue,67,1) = @OverrideON  THEN 'In Override' 
              WHEN SUBSTRING (PointValue,67,1) = @OverrideOFF THEN 'Normal'
              ELSE '**StringError**'
        END as 'HW',
        CASE  WHEN SUBSTRING (PointValue,69,1) = @OverrideON  THEN 'In Override'
              WHEN SUBSTRING (PointValue,69,1) = @OverrideOFF THEN 'Normal'
              ELSE '**StringError**'
        END as 'CHW',
        CASE  WHEN SUBSTRING (PointValue,71,1) = @OverrideON  THEN 'In Override'
              WHEN SUBSTRING (PointValue,71,1) = @OverrideOFF THEN 'Normal'
              ELSE '**StringError**'
        END as 'OAD',
        CASE  WHEN SUBSTRING (PointValue,73,1) = @OverrideON  THEN 'In Override'
              WHEN SUBSTRING (PointValue,73,1) = @OverrideOFF THEN 'Normal'
              ELSE '**StringError**'
        END as 'VFD'
    FROM dbo.Points
    WHERE LogicName like '%override%'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can I execute a test case from Command Console using NUnit? I had
I am trying to realize a use-case using git. Use Case : It should
I am trying to match for country or Country using lower-case function in XPath.
Besides readability is there any significant benifit to using a CASE WHEN statement vs
Newbie in testing. I generated a test case using Selenium, and then exported it
in the case of using PreparedStatement with a single common connection without any pool,
How do I ignore case when using pcre_compile and pcre_exec? pcre_exec( pcre_compile(pattern,0,&error,&erroroffset,0), 0, string,
I am trying to put together a test case for using Lucene.NET on one
Compare using perl -w -Mstrict : # case Alpha print $c; ... # case
Possible Duplicate: Case Order by using Null I'm looking to get a list of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.