• mister.magoo (10/9/2015)


    Lynn Pettis (10/9/2015)


    I tried posting the hard way to do it but can't from here. So, replace the call to dbo.GetInvoiceIDFromBillID with the following to see what I did, just for S & G's.

    right(left(BillID,

    case when charindex('-',BillID) > 0

    then charindex('-',BillID) - 1

    else len(BillID)

    end), len(left(BillID,case when charindex('-',BillID) > 0

    then charindex('-',BillID) - 1

    else len(BillID)

    end)) - patindex('%[0-9]%', left(BillID,case when charindex('-',BillID) > 0

    then charindex('-',BillID) - 1

    else len(BillID)

    end)) + 1)

    ^-- This.

    Or this?

    SUBSTRING( LEFT( BillID, ISNULL( NULLIF( charindex('-',BillID), 0) - 1, 20)), PATINDEX( '%[0-9]%', BillID), 20)

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2