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 |
|
pazzy11
Posting Yak Master
145 Posts |
Posted - 2007-11-16 : 05:29:29
|
| Hi if i wanna search a certain column for a specific character so it could be '&' occuring anywhere in the string can i use the like operator ?so have something like[CODE]SELECT name from tablewhere name like '%&%'[/CODE] |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-11-16 : 05:33:45
|
| yes you can.does that query not work for you?_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
|
pazzy11
Posting Yak Master
145 Posts |
Posted - 2007-11-16 : 05:36:09
|
| yes it does but i was wondering did it cover everything ? is '%&%' different from '%%&%%' ? |
 |
|
|
pazzy11
Posting Yak Master
145 Posts |
Posted - 2007-11-16 : 05:37:00
|
| Another question , what about replacing said char with another one ? can it be done with an UPDATE |
 |
|
|
spirit1
Cybernetic Yak Master
11752 Posts |
Posted - 2007-11-16 : 05:40:32
|
| yes you can . you have to use substring or replace function.look them up in BOL = Books Online ? SQL Server Help_______________________________________________Causing trouble since 1980blog: http://weblogs.sqlteam.com/mladenpSSMS Add-in that does a few things: www.ssmstoolspack.com |
 |
|
|
georgev
Posting Yak Master
122 Posts |
Posted - 2007-11-16 : 08:09:57
|
Just a quick note to point out the other wildcard operator available in SQL Server.The underscore (_)!This can be used to represent a single character, whereas the percentage symbol (%) is used to denote any number of characters above and including zero.[CODE]SELECT *FROM peopleWHERE surname LIKE 'Smit_'[/CODE]Would return values such as "Smith"Whereas[CODE]SELECT *FROM peopleWHERE surname LIKE 'Smit%'[/CODE]Could return "Smith", "Smithson", etc.Hope this helps :) George<3Engaged! |
 |
|
|
arorarahul.0688
Posting Yak Master
125 Posts |
Posted - 2007-11-19 : 07:58:13
|
quote: Originally posted by pazzy11 Another question , what about replacing said char with another one ? can it be done with an UPDATE
in result set (which is returned as a result of query processing it can be done as)you can replace an exp/charracter by another one asinsert into testing values ('wwww@wew@soop@')select replace([name],'@','#') from testingRahul Arora MCA 07 BatchNCCE Israna, PanipatHRY, INDIA######################IMPOSSIBLE = I+M+POSSIBLE |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2007-11-19 : 10:24:09
|
quote: Originally posted by arorarahul.0688
quote: Originally posted by pazzy11 Another question , what about replacing said char with another one ? can it be done with an UPDATE
in result set (which is returned as a result of query processing it can be done as)you can replace an exp/charracter by another one asinsert into testing values ('wwww@wew@soop@')select replace([name],'@','#') from testingRahul Arora MCA 07 BatchNCCE Israna, PanipatHRY, INDIA######################IMPOSSIBLE = I+M+POSSIBLE
While that answer was already given, at least you did add at least something new by providing some sample code. So, still not an original or helpful answer, but I think that perhaps you did (finally) actually add some value to a thread, so good job! Keep it up!- Jeffhttp://weblogs.sqlteam.com/JeffS |
 |
|
|
|
|
|
|
|