• dawoodalgharib (7/11/2009)


    I think that the definition of SUBSTRING statement contains: "If start_expression is less than 1, the returned expression will begin at the first character that is specifed in value_expression".

    So I think this definition meant that:

    SELECT * SUBSTRING('123456',0,3) should return 123.

    Except that (see KB article linked in one of the earliest posts above) there isn an ANSI standard that SQL is conforming to that says if the start position is <1 then return the specified length -1 So yes it's starting at position 1, but it's also adjusting the length.

    so the docs for that defintion of substring need to be updated, to reflect that additional info (as also mentioned above) since clearly the function is behaving as described in the KB, not as one might expect from reading the docs alone.