if error - unable to resolve

ASHMITP 141 Reputation points
2021-05-21T02:57:47.277+00:00

Anyone please let me know why I am getting the below error

98398-rr1.png

Windows for business | Windows Client for IT Pros | User experience | Other
Developer technologies | Transact-SQL
Developer technologies | Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
SQL Server | Other
{count} votes

1 answer

Sort by: Most helpful
  1. MelissaMa-msft 24,246 Reputation points Moderator
    2021-05-21T06:22:06.737+00:00

    Hi @ASHMITP ,

    Welcome to Microsoft Q&A!

    You could use IIF instead of 'if'.

    syntaxsql

    IIF( boolean_expression, true_value, false_value )

    Please refer below:

    select IIF([visit_id]='abd',"yes","No")  
    from dbo.data_pcoc_episode  
    

    Best regards,
    Melissa


    If the answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.