Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3222002
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T15:56:28+00:00 2026-05-17T15:56:28+00:00

How can rows with non-ASCII characters be returned using SQL Server? If you can

  • 0

How can rows with non-ASCII characters be returned using SQL Server?
If you can show how to do it for one column would be great.

I am doing something like this now, but it is not working

select *
from Staging.APARMRE1 as ar
where ar.Line like '%[^!-~ ]%'

For extra credit, if it can span all varchar columns in a table, that would be outstanding! In this solution, it would be nice to return three columns:

  • The identity field for that record. (This will allow the whole record to be reviewed with another query.)
  • The column name
  • The text with the invalid character
 Id | FieldName | InvalidText       |
----+-----------+-------------------+
 25 | LastName  | Solís             |
 56 | FirstName | François          |
100 | Address1  | 123 Ümlaut street |

Invalid characters would be any outside the range of SPACE (3210) through ~ (12710)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T15:56:28+00:00Added an answer on May 17, 2026 at 3:56 pm

    try something like this:

    DECLARE @YourTable table (PK int, col1 varchar(20), col2 varchar(20), col3 varchar(20));
    INSERT @YourTable VALUES (1, 'ok','ok','ok');
    INSERT @YourTable VALUES (2, 'BA'+char(182)+'D','ok','ok');
    INSERT @YourTable VALUES (3, 'ok',char(182)+'BAD','ok');
    INSERT @YourTable VALUES (4, 'ok','ok','B'+char(182)+'AD');
    INSERT @YourTable VALUES (5, char(182)+'BAD','ok',char(182)+'BAD');
    INSERT @YourTable VALUES (6, 'BAD'+char(182),'B'+char(182)+'AD','BAD'+char(182)+char(182)+char(182));
    
    --if you have a Numbers table use that, other wise make one using a CTE
    WITH AllNumbers AS
    (   SELECT 1 AS Number
        UNION ALL
        SELECT Number+1
            FROM AllNumbers
            WHERE Number<1000
    )
    SELECT 
        pk, 'Col1' BadValueColumn, CONVERT(varchar(20),col1) AS BadValue --make the XYZ in convert(varchar(XYZ), ...) the largest value of col1, col2, col3
        FROM @YourTable           y
            INNER JOIN AllNumbers n ON n.Number <= LEN(y.col1)
        WHERE ASCII(SUBSTRING(y.col1, n.Number, 1))<32 OR ASCII(SUBSTRING(y.col1, n.Number, 1))>127
    UNION
    SELECT 
        pk, 'Col2' BadValueColumn, CONVERT(varchar(20),col2) AS BadValue --make the XYZ in convert(varchar(XYZ), ...) the largest value of col1, col2, col3
        FROM @YourTable           y
            INNER JOIN AllNumbers n ON n.Number <= LEN(y.col2)
        WHERE ASCII(SUBSTRING(y.col2, n.Number, 1))<32 OR ASCII(SUBSTRING(y.col2, n.Number, 1))>127
    UNION
    SELECT 
        pk, 'Col3' BadValueColumn, CONVERT(varchar(20),col3) AS BadValue --make the XYZ in convert(varchar(XYZ), ...) the largest value of col1, col2, col3
        FROM @YourTable           y
            INNER JOIN AllNumbers n ON n.Number <= LEN(y.col3)
        WHERE ASCII(SUBSTRING(y.col3, n.Number, 1))<32 OR ASCII(SUBSTRING(y.col3, n.Number, 1))>127
    order by 1
    OPTION (MAXRECURSION 1000);
    

    OUTPUT:

    pk          BadValueColumn BadValue
    ----------- -------------- --------------------
    2           Col1           BA¶D
    3           Col2           ¶BAD
    4           Col3           B¶AD
    5           Col1           ¶BAD
    5           Col3           ¶BAD
    6           Col1           BAD¶
    6           Col2           B¶AD
    6           Col3           BAD¶¶¶
    
    (8 row(s) affected)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

one of my SQL queries is returning non-printable characters in the data because of
I know that I can insert multiple rows using a single statement, if I
Does anybody know how I can get the number of the elements (rows*cols) returned
What SQL can be used to list the tables, and the rows within those
how can I make certain rows editable and certain rows non-editable of a datawindow?
I was wondering how you can insert multiple rows into a MySQL database using
I am trying to create a databound WPF GridView whose rows can either be
Problem: a table of coordinate lat/lngs. Two rows can potentially have the same coordinate.
I know that you can insert multiple rows at once, is there a way
I have rows of text data that can vary between 0 and 100, and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.