Results 1 to 4 of 4

Thread: Sql Error

  1. #1
    Join Date
    Oct 2006

    Unanswered: Sql Error

    Could someone please help me out. I keep getting this error:

    Server: Msg 536, Level 16, State 3, Line 1
    Invalid length parameter passed to the substring function.
    The statement has been terminated.

    whennever i run this update statement:
    Update ctblrph_SS_Telephones1
    SET TelNo2=SUBSTRING(TelNo1, 1, LEN(TelNo1) - 1) + SUBSTRING(Extension,1,CHARINDEX('/', Extension + '/') - 1),
    TelNo3= SUBSTRING(TelNo1, 1, LEN(TelNo1) - 1) + SUBSTRING(Extension,CHARINDEX('/', Extension + '/')+3,LEN(Extension)),
    TelNo4=SUBSTRING(TelNo1, 1, LEN(TelNo1) - 1) + SUBSTRING(Extension,CHARINDEX('/', Extension + '/')-1,LEN(Extension))
    WHERE (LEN(Extension) > 3) AND (Extension LIKE '%/%')
    What is causing the problem?

  2. #2
    Join Date
    Nov 2004
    on the wrong server
    Provided Answers: 6
    can TelNo1 be null?
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

  3. #3
    Join Date
    Oct 2006
    No,absolutely not.

  4. #4
    Join Date
    Nov 2006
    The error could be because the substring function get length (third parameter) lower than 0.

    Try to find records with len(TelNo1) = 0 using syntax like that:

    HTML Code:
    select *
    from ctblrph_SS_Telephones1
    where len(TelNo1) = 0

    If you find anything, you should modify your query adding another condition to the where clause or case when to the set section.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts