简体   繁体   中英

MS Sql - Escape special characters in large text

inserting large HTML into an SQL table, I need to escape all quotes and other special characters. I know that in C# I can simply do this:

myString = @"<p> this is my paragraph </p>";

can I do this in MS SQL?

You mean you're trying to run a text query, like in SSMS? I think the only thing that needs to be escaped is the ' so you should be able to select the text block, and do a find-replace to replace ' with '' .

Note: If you are running this from code though, you should be using a parameterized query, pure and simple.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM