Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


how to find ASCII characters in a table?


how to find ASCII characters in a table?

Author
Message
ranuganti
ranuganti
Valued Member
Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)

Group: General Forum Members
Points: 58 Visits: 545
Can any one tell me the sql query to find the ASCII characters (0 to 127) from multiple columns in a table.

Thanks.
Lowell
Lowell
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14959 Visits: 38977
failrly easy to generate your own table of ascii chars, but i don't understand what you meant by from mulitple columns;

can you explain what you were after?
here's one example:


with Tally (N)
AS
( select top 127 row_number() over (Order By Name) from sys.columns
)
select N-1 as CHARVALUE,CHAR(N-1) as ASCIICHAR
from Tally



Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

ranuganti
ranuganti
Valued Member
Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)

Group: General Forum Members
Points: 58 Visits: 545
I have a table in which a couple of columns (varchar) is having ASCii characters so how do i find them using a sql query?

Thanks.
Jeff Moden
Jeff Moden
SSC-Forever
SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)

Group: General Forum Members
Points: 45127 Visits: 39923
ranuganti (7/29/2011)
I have a table in which a couple of columns (varchar) is having ASCii characters so how do i find them using a sql query?

Thanks.


ALL characters in a varchar column are ASCII characters. Which characters are you looking for? Just "control" characters such as TABs, CARRIAGE RETURNs, LINEFEEDs, etc?

--Jeff Moden

RBAR is pronounced ree-bar and is a Modenism for Row-By-Agonizing-Row.
First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
Although they tell us that they want it real bad, our primary goal is to ensure that we dont actually give it to them that way.
Although change is inevitable, change for the better is not.
Just because you can do something in PowerShell, doesnt mean you should. Wink

Helpful Links:
How to post code problems
How to post performance problems
Forum FAQs
ranuganti
ranuganti
Valued Member
Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)

Group: General Forum Members
Points: 58 Visits: 545
Yes
Lowell
Lowell
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14959 Visits: 38977
ranuganti (7/29/2011)
I have a table in which a couple of columns (varchar) is having ASCii characters so how do i find them using a sql query?

Thanks.


you are still not clear. if you have two rows of data in the varchar table you are talking about, say that had the values "MIAMI" and "DALLAS", what would be the expected results?

Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

ranuganti
ranuganti
Valued Member
Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)

Group: General Forum Members
Points: 58 Visits: 545
Yes, am looking for the special charaacters in the column other than numbers and the alphabets.

Thanks.
bitbucket-25253
bitbucket-25253
SSCertifiable
SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)SSCertifiable (5.7K reputation)

Group: General Forum Members
Points: 5689 Visits: 25280
Is this what you desire to do?
CREATE TABLE #T(Id INT,SomeText VARCHAR(300))
INSERT INTO #T
SELECT 9,'This is 1 Tab' UNION ALL
SELECT 13, 'This is a
line feed' UNION ALL
SELECT 1000,'This has a tab and a line
feed' --edited ,, us a tab, carriage return and a line feed
----single tab character in between % in first LIKE and a carriage return and Line feed in second LIKE
SELECT ID FROM #T WHERE SomeText LIKE '% %' OR SomeText LIKE '%
%'


Displaying the results as text using SSMS
Id          SomeText
----------- -------------------
9 This is 1 Tab
13 This is a
line feed
1000 This has a tab and a line
feed



Edited to correct tab, carriage return and line feed useage

If everything seems to be going well, you have obviously overlooked something.

Ron

Please help us, help you -before posting a question please read

Before posting a performance problem please read
ranuganti
ranuganti
Valued Member
Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)Valued Member (58 reputation)

Group: General Forum Members
Points: 58 Visits: 545
I have this type of ASCii characters in the column how do i find all in a single query other than alphanumarics.

Thanks,
(space)
!
"
#
$
%
&
'
(
)
*
+
,
-
.
/
:
;
<
=
>
?
Lowell
Lowell
SSChampion
SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)SSChampion (14K reputation)

Group: General Forum Members
Points: 14959 Visits: 38977
here's one way:

select * from YOURTABLE where PATINDEX('%[ !"#$%&''()*+,-./:;<=>?]%',YOURCOLUMN) > 0
--or
select * from YOURTABLE where YOURCOLUMN LIKE '%[ !"#$%&''()*+,-./:;<=>?]%'



Lowell

--
help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search