Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Special Characters

Author  Topic 

kid_on_the_block
Posting Yak Master

172 Posts

Posted - 2006-01-16 : 09:22:19
Hi All

I have a database I want to check whether any special characters are entered or not

E.g.

Post
-------

Director
Asst*Director
Ma^nager

I want to see all the entires where special characters like !@#$%^&*()_+ are entered

Plz help

Thanks



madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-16 : 09:28:09
Start with this

Select * from
(select 'test' as data union all select '^sdf' union all
select 'testing&' union all select 'select *'
) t where data like '%[!@#$%^&*()_+]%'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

kid_on_the_block
Posting Yak Master

172 Posts

Posted - 2006-01-16 : 09:31:37
thanks madhivanan , can you get online on the yahoo plz
Go to Top of Page

kid_on_the_block
Posting Yak Master

172 Posts

Posted - 2006-01-16 : 09:41:30
am not able to get it, can you plz explain it in more details

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-16 : 09:44:36
That query will take data which has atleast one of !@#$%^&*()_+

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

kid_on_the_block
Posting Yak Master

172 Posts

Posted - 2006-01-16 : 10:12:50
ok , now if i had only one column say "Post"
I would say :- Select * from table where Post like '%[!@#$%^&*()_+]%'


& what if i had 10 columns, would I have to write

Select * from table where Col1 like '%[!@#$%^&*()_+]%'
go
Select * from table where Col2 like '%[!@#$%^&*()_+]%'
....



etc

Plz help


Thanks




Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-16 : 23:59:58
Select * from table where Col1 like '%[!@#$%^&*()_+]%' or Col2 like '%[!@#$%^&*()_+]%' or ,....
ColN like '%[!@#$%^&*()_+]%'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

kid_on_the_block
Posting Yak Master

172 Posts

Posted - 2006-01-19 : 11:03:00
hey I typed the following :-

Select emailid from Table where emailid like '%[~`!#$%^&*()-+=?|\/,;:]%'

It shows me


xxx@xxx.COM
xxxx@xxxxxxxx.COM


Why ??? I have not seacrhed for :- @ . .... then why ?????


Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-01-20 : 00:44:30
No it wont return them

Select * from
(
select 'test' as data union all select '^sdf' union all
select 'testing&' union all select 'select *' union all
select 'xxx@xxx.COM' union all
select 'xxxx@xxxxxxxx.COM'
) t
where data like '%[!#$%^&*()_+]%'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -