| Author |
Topic |
|
masterdineen
Aged Yak Warrior
550 Posts |
Posted - 2010-09-07 : 09:28:09
|
| Hello everyone.I am querying a database with tons of addresses that i want to query. But the problem is, a lot of data has comma's within the addresses for example. Flat 1, Edith Bell Housewhat syntax would i use to ignore the ',' when querying.I dont want to delete, just ignore when querying.Kind RegardsRobMCTS / MCITP certified |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-09-07 : 09:38:01
|
| where replace(address,',','')='some address'MadhivananFailing to plan is Planning to fail |
 |
|
|
masterdineen
Aged Yak Warrior
550 Posts |
Posted - 2010-09-07 : 09:39:38
|
| Hello Madhivanan what if i have lots of ',' within the query |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-09-07 : 09:48:14
|
quote: Originally posted by masterdineen Hello Madhivanan what if i have lots of ',' within the query
It will take careMadhivananFailing to plan is Planning to fail |
 |
|
|
masterdineen
Aged Yak Warrior
550 Posts |
Posted - 2010-09-07 : 09:54:57
|
| Am i on the right lines with something like thisdeclare @address varchar(1)set @address = ','select * from FMW_Auto_2where replace (@address,',','') |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-09-07 : 10:12:26
|
quote: Originally posted by masterdineen Am i on the right lines with something like thisdeclare @address varchar(1)set @address = ','select * from FMW_Auto_2where replace (@address,',','')
declare @address varchar(1)set @address = 'Flat 1'select * from FMW_Auto_2where replace (address,',','') like '%'+@address+'%'MadhivananFailing to plan is Planning to fail |
 |
|
|
masterdineen
Aged Yak Warrior
550 Posts |
Posted - 2010-09-07 : 10:17:33
|
| thank you..buttried this and does not work. butwhy are you setting @address = 'flat' when i want this to replace all of the ',' within the query result. |
 |
|
|
masterdineen
Aged Yak Warrior
550 Posts |
Posted - 2010-09-07 : 10:34:37
|
| I am trying the followingselect * from FMW_Auto_2where replace (',',',','') and i receive the following errorMsg 4145, Level 15, State 1, Line 2An expression of non-boolean type specified in a context where a condition is expected, near ')'what would be a good example of expected condition |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2010-09-08 : 05:08:54
|
| select address,replace(address,',','') as address_no_comma from FMW_Auto_2MadhivananFailing to plan is Planning to fail |
 |
|
|
|