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.
Author |
Topic |
Dhanushkodi
Starting Member
21 Posts |
Posted - 2013-04-30 : 06:48:00
|
I have written the query with like select type from table where type1 like '%sd%'my data have "%" symbol. so how can i write the query to search the data.if i write the query like thisselect type from table where type1 like '%%%'it wont working. it bring all the records. so help me out. thanks |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-04-30 : 07:00:47
|
do you mean this?select type from table where type1 like '%^%sd%' ESCAPE '^'------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-04-30 : 07:01:31
|
http://visakhm.blogspot.in/2013/01/wildcard-character-based-pattern-search.html------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
Dhanushkodi
Starting Member
21 Posts |
Posted - 2013-05-03 : 02:29:20
|
thank you visakh16. Now my query is working.whats my doubt is, i have the following data in my table FORM HE2. %when i write the query as select * from wildChars where charss like '%^%%'. it's bring the following dataTEST!@#$%^&*~!@#$%^&*i have the data like "FORM HE2. %". it's not coming. it's contains "Space". please help me out to write the query. |
|
|
bandi
Master Smack Fu Yak Hacker
2242 Posts |
Posted - 2013-05-03 : 02:42:55
|
select * from wildChars where charss like '%^%%' ESCAPE '^'If you want only data which contains % (percentage) symbol, you can use select * from @tab where col like '%[%]%'--Chandu |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-03 : 03:13:34
|
quote: Originally posted by Dhanushkodi thank you visakh16. Now my query is working.whats my doubt is, i have the following data in my table FORM HE2. %when i write the query as select * from wildChars where charss like '%^%%'. it's bring the following dataTEST!@#$%^&*~!@#$%^&*i have the data like "FORM HE2. %". it's not coming. it's contains "Space". please help me out to write the query.
its because you didnt specify ^ as a escape character using ESCAPE------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
Dhanushkodi
Starting Member
21 Posts |
Posted - 2013-05-03 : 03:37:47
|
thanks for your help. query is running perfectly. thanks a lot. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-05-03 : 04:16:55
|
welcome------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|