1

here I wanted to check if coming value is empty string or null then use value from Db column.Like I did for is null case. How can i check for empty string in this line of code.Please suggest

II.[NAME] = isNull(IIMODEL.[Name], II.[NAME]), 
2
  • Can I use Case for this? Commented Jul 18, 2020 at 7:09
  • What is the "incoming" value? Commented Jul 18, 2020 at 12:11

3 Answers 3

2
II.[NAME] = ISNULL(NULLIF(TRIM(IIMODEL.[NAME]), ''), II.[NAME])
Sign up to request clarification or add additional context in comments.

1 Comment

this works , I also tried using Case that also works,Like this II.[NAME]=CASE WHEN IIMODEL.[Name] = null THEN II.[NAME] WHEN IIMODEL.[Name] = '' THEN II.[NAME] ELSE IIMODEL.[Name] END
1

Why not just use explicit comparisons?

(II.[NAME] = IIMODEL.[Name] OR IIMODEL.[Name] IS NULL OR IIMODEL.[Name] = '')

I think the logic is much simpler to follow.

Comments

1
case when isnull([column], '') <> '' then [column] else [other] end

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.