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,

SQL Server
SQL Server
A family of Microsoft relational database management and analysis systems for e-commerce, line-of-business, and data warehousing solutions.
12,955 questions
Transact-SQL
Transact-SQL
A Microsoft extension to the ANSI SQL language that includes procedural programming, local variables, and various support functions.
4,566 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Erland Sommarskog 1L Reputation points
    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.