• You need CHARINDEX() to find the position of the second dash (if it exists).

    This almost works:

    use tempdb;

    go

    SELECT OrderNo

    , CHARINDEX('-',OrderNo,4) AS FindDash

    , LEFT(OrderNo,CHARINDEX('-',OrderNo,4)) AS NoSuffix

    FROM (

    SELECT 'SO-123456' AS OrderNo

    UNION ALL

    SELECT 'SO-123456-01'

    UNION ALL

    SELECT 'SO-123456-2'

    UNION ALL

    SELECT 'SO-123457'

    UNION ALL

    SELECT 'SO-123457-1'

    UNION ALL

    SELECT 'SO-123457-02'

    UNION ALL

    SELECT 'SO-123458') x

    If you set up your question so that people can answer it really easily, (by providing readily consumable code/SELECT statements), you'll get more answers, because people won't have to work as hard to solve your problem. I usually find that setting up the question properly gets me most of the way to the answer too.

    HTH,

    Pieter