SDU Tools: Quote a T-SQL String

I’m not a great fan of dynamic SQL (where you create a T-SQL command in code, then execute the command) but there are times when you just need to do it.

When creating dynamic SQL, it can get very painful trying to work out which strings are quoted and how many quotes you need.

To make this a bit easier, in our free SDU Tools, we added a function for QuoteString.

You can see its action in the screenshot above.

I puts an opening and closing quote around a string, but also doubles up any quotes contained within the string.

You can see it in action here:

For more information on our free SDU Tools and to get a copy of these and our other free resources by becoming an SDU Insider, follow this link:

http://sdutools.sqldownunder.com

 

Leave a Reply

Your email address will not be published. Required fields are marked *