For my edification - please

  • I had a contractor pass me a query to run in our production environment and though that it would never work. I tried it in my test area and was surprised that it ran as expected. Can some one help me understand why

    UPDATE

    TTASK

    SET

    BILLABLE = 1 ,

    COSTED = 1 ,

    FUNDED = 1

    WHERE

    ( { fn LENGTH(ID) } = 16 )

    AND ( FUNDED = 0 )

    OR ( { fn LENGTH(ID) } = 16 )

    AND ( COSTED = 0 )

    OR ( { fn LENGTH(ID) } = 16 )

    AND ( BILLABLE = 0 )

    Has the same affect as:

    UPDATE

    TTASK

    SET

    BILLABLE = 1 ,

    COSTED = 1 ,

    FUNDED = 1

    WHERE

    ( LEN(ID) = 16

    AND FUNDED = 0 )

    OR ( LEN(ID) = 16

    AND COSTED = 0 )

    OR ( LEN(ID) = 16

    AND BILLABLE = 0 )

    Both work correctly from Management Studio

    Yours perplexed

    Stuart

    -------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
    There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
    I would never join a club that would allow me as a member - Groucho Marx

  • {fn length} is a Microsoft ODBC canonical function that is supposed to work the same with any data type.


    Forever trying to learn
    My blog - http://www.cadavre.co.uk/
    For better, quicker answers on T-SQL questions, click on the following...http://www.sqlservercentral.com/articles/Best+Practices/61537/
    For better, quicker answers on SQL Server performance related questions, click on the following...http://www.sqlservercentral.com/articles/SQLServerCentral/66909/

  • curly brackets like that are for ODBC escape sequencing. It'll work... most of the time, but you might get really strange results some of the time. I wouldn't do it. Ever.

    "The credit belongs to the man who is actually in the arena, whose face is marred by dust and sweat and blood"
    - Theodore Roosevelt

    Author of:
    SQL Server Execution Plans
    SQL Server Query Performance Tuning

  • Thanks for the replies. Makes sense knowing the full history - the code snippet comes from an API.

    I'll make the simple mods required to make it T-SQL

    -------------------------------Posting Data Etiquette - Jeff Moden [/url]Smart way to ask a question
    There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
    I would never join a club that would allow me as a member - Groucho Marx

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

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