Joel
4Penny.net
Points: 10550

10/11/2011 10:07:48 AM

SQL - Loop through a string and show all the ASCII characters

* This article, and all our great SQL (General) documentation, Is available on the SQL (General) menu

This short script will show how to loop through a string in T-SQL and display the ASCII characters.

Why would you need to do this? Sometime you need to see (visibly) the placement of non printable characters in a string, like CR (ASCII 13), LF (ASCII 10) or TAB (ASCII(9). This script does that. The output will look take text that look like this:

And show this:

4Penny.net
Version: Unknown or N/A
Section: SQL Scripts
Table Definition Quick Links
All Tables
SOP Tables
RM Tables
GL Tables
POP Tables
HR Tables
PM Tables
UPR Tables
IV Tables
Olympic Tables
3