Delete Specific Record

  • Search from a column where values contains once space and after then any character other than space, but did not delete those who has two or more than 2 spaces continuous.

  • It's going to be a bit slow but something like the following will do it...

    SELECT columnlist

    FROM dbo.SomeTable

    WHERE (SomeColumn LIKE '%[^ ] [^ ]%' OR SomeColumn LIKE ' [^ ]%')

    AND SomeColumn NOT LIKE '% %'

    ;

    Seems like homework though... you need to be able to explain it. Lookup "LIKE" in Books Online. If you don't know what "Books Online for SQL Server" is, you might want to spend some time on that, as well.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

Viewing 2 posts - 1 through 1 (of 1 total)

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