ISNULL question

  • I have difficult understanding this line of code

    where ISNULL(myfield, 'N') = 'Y'

    Does this mean

    where myfeild is NULL or myfield = 'N' or myfield = 'Y'

  • SQL_Surfer (4/10/2013)


    I have difficult understanding this line of code

    where ISNULL(myfield, 'N') = 'Y'

    Does this mean

    where myfeild is NULL or myfield = 'N' or myfield = 'Y'

    The string value 'N' will be provided for the comparision if the value of the column myfield is null.

    Personally, I would simply use WHERE myfield = 'Y'. As it is currently coded the clause is not SARGable and will most likely not use an index on the column if one exists.

  • What Lynn said.

    Documentation is you need it: http://msdn.microsoft.com/en-us/library/ms184325.aspx

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply