• RBarryYoung (6/8/2009)


    karthikeyan (6/8/2009)


    4) What LHS (Left-hand side) function denotes exactly?

    Left-hand Functions appear left of the assignment operator ("="):

    Set @STR = UPPER('Some text.')

    These are normal functions, and AFAIK, in T-SQL, all functions are LHS.

    3) What RHS (right-hand side) function denotes exactly?

    Right-hand Side functions appear on the right-hand side and they usually do "special" things having to do with addressing the output property or variable. AFAIK, T-SQL does not have any, but in some languages, STUFF is a RHS:

    STUFF(@str, offset, len) = 'foo'

    This example would overwrite the output string (@str) with the input string starting at 'offset' for 'len' characters. The difference between this and th LHS STUFF() function in T-SQL is that the RHS version does not return anything, it actually does write over the characters of the @STR variable.

    3) The "pre-allocate and Stuff" trick popular with mutable strings is not workable in T-SQL because the STUFF() function in T_SQL is NOT like the function of the same name in some general purpose languages: the T-SQL STUFF() is an RHS (right-hand side) function and NOT an LHS (left-hand side) function. AFAIK, there is no function in SQL that can (physically) write into a pre-existing string.

    RBarryyoung,

    The above two points are confusing me...

    you mean to say TSQL STUFF() function can't write into a pre-existing string.

    karthik