Home Forums SQL Server 2008 T-SQL (SS2K8) Remove the first two characters in a column value if they meet a certain condition RE: Remove the first two characters in a column value if they meet a certain condition

  • eklavu (12/20/2012)


    UPDATE #TEST_TABLE

    SET COLS = SUBSTRING(COLS,3,LEN(COLS)-2)

    WHERE LEFT(COLS,2) = 'NA'

    Possibly not relevant here, but if the 'COLS' column is indexed, a better option would be

    where cols like 'NA%'

    As this will make use of the index, whereas the LEFT function is non-SARGable and will not.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.