Home Forums SQL Server 2005 T-SQL (SS2K5) Deleting all characters to the right of char(13) or char(10). RE: Deleting all characters to the right of char(13) or char(10).

  • Give this a try:

    with basedata as ( -- creating test data

    select

    *

    from

    (values ('INTERNAL COMMUNICATIONS:' + Char(13) + 'Blah blah blah blah'),

    ('NOTES/MEMOS:' + Char(13) + 'This is a random note. It could go on for up to 200+ charaters, etc.'),

    ('INTERNAL COMMUNICATIONS:' + Char(10) + 'Blah blah blah blah'),

    ('NOTES/MEMOS:' + Char(10) + 'This is a random note. It could go on for up to 200+ charaters, etc.'))dt(TestStr)

    )

    select

    *,

    left(TestStr,patindex('%[' + char(13) + char(10) + ']%', TestStr) - 1)

    from

    basedata