Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 

Get your favourite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved in your SSC briefcase from the favorites tab.
Download now (direct download link)

Function to find non-printable characters

By Damien Alvarado,

I came across some non printable characters during an extract from a database. Some columns had control characters like TAB, BS, LF and so on. When these got into the extract they caused some downstream processes to fail because the TAB character was also used as a delimiter. I now have to figure out where these bad characters came from and eliminate them but I was able to quickly fix the feed by applying this function in my extract code.

I use the function in the following way

 

SELECT

CASE WHEN dbo.HasNonPrintableChar(column_1) = 0 THEN column_1 ELSE NULL END AS column_1

FROM table_1

 

I am now assured that I will only pass printable ASCII in the output of my query. The function uses the ASCII function and searches for values outside of the printable range. Enjoy!

Total article views: 1394 | Views in the last 30 days: 2
 
Related Articles
FORUM

Non-printable characters in SQL Scripts out of SSMS?

Using Script as Create results in scripts with non-printable characters

FORUM

Extract Number From Alphanumeric Character

Extract Number From Alphanumeric Character

FORUM

Function to find non-printable characters

Comments posted to this topic are about the item [B]Function to find non-printable characters[/B] a ...

FORUM

character limitations on sp name, & function name

character limitations on sp name, & function name

FORUM

Remove non printable characters

Hi, Is there an equivilent function to Excel's 'CLEAN' in SQL to remove non printable characters?. ...

 
Contribute

Join the most active online SQL Server Community

SQL knowledge, delivered daily, free:

Email address:  

You make SSC a better place

As a member of SQLServerCentral, you get free access to loads of fresh content: thousands of articles and SQL scripts, a library of free eBooks, a weekly database news roundup, a great Q & A platform… And it’s our huge, buzzing community of SQL Server Professionals that makes it such a success.

Join us!

Steve Jones
Editor, SQLServerCentral.com

Already a member? Jump in:

Email address:   Password:   Remember me: Forgotten your password?
Steve Jones