charindex

  • Hi Guys,Im getting tis error for this,whats wrong in this ?can anybody suggest me?

    I am doing UPDATE #temp SET

    Fname = LEFT(Logins, CHARINDEX(',', Logins)-1)

    Msg 536, Level 16, State 5, Line 1

    Invalid length parameter passed to the SUBSTRING function.

    The statement has been terminated.

  • You have not passed the start value for the charindex function.

    Ex:- CHARINDEX(',', Logins,1)

    "Keep Trying"

  • ',' is not found in the string so charindex()-1 is returning -1 which is an invalid length.

  • swekik (5/29/2008)


    Hi Guys,Im getting tis error for this,whats wrong in this ?can anybody suggest me?

    I am doing UPDATE #temp SET

    Fname = LEFT(Logins, CHARINDEX(',', Logins)-1)

    Msg 536, Level 16, State 5, Line 1

    Invalid length parameter passed to the SUBSTRING function.

    The statement has been terminated.

    You need to add:

    Where CHARINDEX(',', Logins) > 0

    to it.

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

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

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