SQL: Specifies that the name does not find the data's extension ~ Space line break character return batch processing

Source: Internet
Author: User

Exception handling Rollup-database family http://www.cnblogs.com/dunitian/p/4522990.html

Let's see what happens.

Copy the query to the data, paste it to see what the situation

then batch processing ~

That's it? NoNoNo, stretch a bit ~ our various lazy (the world is lazy people change)

Simple Package First

--Preliminary package
DECLARE @cloumnName varchar = ' tname '
Update Shopmenutype set @cloumnName =replace (@cloumnName, char (Ten), ")---remove line break
Update Shopmenutype set @cloumnName =replace (@cloumnName, char (+), ')---remove carriage return
Update Shopmenutype set @cloumnName =replace (@cloumnName, ', ')---remove whitespace

Try to be able to encapsulate in depth

Final package (can also be simplified, if there is a better way to welcome the post, the inverse day grateful)

DECLARE @tableName varchar, @cloumnName varchar, @sqlStr nvarchar (1000)
Select @tableName = ' Shopmenutype ', @cloumnName = ' tname '--each time you replace the table name and column name here.
Set @sqlStr = ' Update ' [email protected]+ ' Set ' [email protected]+ ' =replace (' [Email protected]+ ', char (), ' ') '--- Remove line breaks
Set @[email protected]+ ' Update ' [email protected]+ ' Set ' [email protected]+ ' =replace (' [Email protected]+ ', char (13), ' ' ') '---remove carriage return
Set @[email protected]+ ' Update ' [email protected]+ ' Set ' [email protected]+ ' =replace (' [Email protected]+ ', ' ' ', ' ') '- --Remove whitespace
Print @sqlStr
EXEC (@sqlStr)

SQL: Specifies that the name does not find the data's extension ~ Space line break character return batch processing

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.