Replace All New Line Characters

  • Hello Everyone

    I hope that you all are having a great monday so far.

    I am working with a large amount of text data in a single column. I am in the process of pumping that column of data into a delimited text file. The data in the column has new line characters that I need to remove. I need to data to be in a single line in the text file. I wish that I could give a sample of the data, but I am sorry that I cannot

    So far the things that I have tried are not working. What can you suggest I try for removing the new line characters?

    Thank you in advance for your suggestions, comments, and time

    Andrew SQLDBA

  • AndrewSQLDBA (5/19/2014)


    Hello Everyone

    I hope that you all are having a great monday so far.

    I am working with a large amount of text data in a single column. I am in the process of pumping that column of data into a delimited text file. The data in the column has new line characters that I need to remove. I need to data to be in a single line in the text file. I wish that I could give a sample of the data, but I am sorry that I cannot

    So far the things that I have tried are not working. What can you suggest I try for removing the new line characters?

    Thank you in advance for your suggestions, comments, and time

    Andrew SQLDBA

    What have you tried?

    Something like this work?

    replace(replace(YourVarcharColumn, char(10), ''), char(13), '')

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/

  • Do replace char(13)+char(10) with '' ( empty string)

    😎

    Edit: character code.

  • Thank you Everyone

    I was actually trying to do this the long roud about hard way. I did not think about using Char() number, I was trying to actually use the value. The way that you both suggested was so much easier and simple.

    I have not had a day off in some time, I think it is time.

    Thank you both very much

    Andrew SQLDBA

Viewing 4 posts - 1 through 3 (of 3 total)

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