About this question
Is it possible to use an IF clause within a WHERE clause in MS SQL?
Example:
WHERE
IF IsNumeric(@OrderNumber) = 1
OrderNumber = @OrderNumber
ELSE
OrderNumber LIKE '%' + @OrderNumber + '%'
Is it possible to use an IF clause within a WHERE clause in MS SQL?
Example:
WHERE
IF IsNumeric(@OrderNumber) = 1
OrderNumber = @OrderNumber
ELSE
OrderNumber LIKE '%' + @OrderNumber + '%'
Log in to share your answer and help other learners.
Log in to answerBest Answer · By JanBask Tableau Expert
Answered on Jul 12, 2021
To use an IF clause within a WHERE clause, you can try using the CASE statement like this:
WHERE OrderNumber LIKE
CASE WHEN IsNumeric(@OrderNumber) = 1 THEN
@OrderNumber
ELSE
'%' + @OrderNumber
END
Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.
Most-read guides across JanBask
Common Tableau interview questions, answered
Guides, tips and career advice on Tableau from JanBask experts.
Tableau Tableau Career Opportunities: What You Need to Know About Tableau in 2025
Master Tableau and land your dream data visualization job. This blog explores Tableau careers, why Tableau is in-demand, and the…
Tableau Tableau Developer Salary for Beginners & Professionals: 2025 Updated Figures
Looking for average Tableau Developer salary? Know how much salary of Tableau Developer to expect based on experience, top…
Tableau Tableau Career Path: Roles, Skills & Certifications
Learn about the different job roles and skills required for a successful Tableau career. Discover how to advance your career with…
Tableau Learn Tableau: Master the Most In Demand Course & Certification
Learn Tableau and harness the power of data visualization. Discover the benefits of Tableau certification and Tableau career…