Replace line breaks and carriage returns in the SQL field.

Source: Internet
Author: User

Replace the linefeed in the SQL field. Carriage Return:

In rich text content, carriage return and line feed are usually displayed. In the SQL database, the carriage return and line break are displayed as spaces after HTML is output.

This is found in data export and import. Generally, the carriage return and line break are found and replaced with <br>.

 

The SQL function is used here. Replace (string_expression, string_pattern, string_replacement), the first parameter: The field to be searched. Second parameter: the character to be searched. Third parameter: the character to be replaced.

Char (9) Horizontal tab char (10) line feed key char (13) Return key
 

1> carriage return char (13)

Select *, replace (detail, char (13), '<br>') as shows the replaced content from test

2> linefeed

Select *, replace (detail, char (10), '<br>') as shows the replaced content from test

3> enter a line break

Select *, replace (detail, char (13) + char (10), '<br>') as show the replaced content from test

4> Replace the carriage return with the line break <br>

Update Test
Set Detail = Replace (detail, char (13) + char (10), '<br> ')

 

 

 

Update t_news set content = Replace (content, char (13) + char (10), '<br>') Where news_type = 3

Add two spaces in front of the content, with the full width
Update t_news set content = ''+ content where news_type = 3

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.