SSMS not flagging basic errors after IIF statement

AdamG Devl 0 Reputation points
2024-05-20T15:07:50.28+00:00

DMF_SSMS_SQL_IIF_Err.pdf

I just wanted to notify Microsoft of an error I believe I found with SSMS error notification. Going thru some scripts, I came across one that had a CASE and IIF in it. I accidently did a typo, no errors, but failed. I then realized that no errors showed up below the IIF. I also couldn't reference table cols with the TABLE. notation.

However, I couldn't open a ticket anywhere, I tried calling, it said go online and open a ticket, then it hung up on me, ha :)

I attached a PDF with a couple 'views' to describe. I had to do screen clippings to show the highlighted errors.

Once I understood what was happening, it doesn't really seem to mess anything up. Hopefully this can get to someone to look at.

Thanks,

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. Erland Sommarskog 128.7K Reputation points MVP Volunteer Moderator
    2024-05-21T20:55:12.1166667+00:00

    I was able to reproduce the issue with this script:

    CREATE VIEW murre AS
        SELECT o.name as objname,
               o.create_date,
               c.name AS colname,
               iif(c.column_id % 2 = 0, 'Odd', 'Even') AS OddEven,
               c.NoSuchCol
        FROM   sys.columns c
        JOIN   sys.objects o ON o.object_id = c.object_id
    

    It looks like this:

    User's image

    But if I uncomment the IIF, I see:

    User's image

    Also, please share the link to the feedback item.

    PS I note the NOLOCK in your view. That is very bad practice. In essence it means "I don't care if I get the correct result or not".

    1 person found this answer helpful.

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.