| | |
MSSQL charindex HELP !
Please support our MS SQL advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Oct 2008
Posts: 1
Reputation:
Solved Threads: 0
Hi all
I am pretty new to MSSQL and have a problem. The solution is probably very simple but I cant find it
I have a database field ZIP, I also have string with consists of a number of UK part postcodes eg
'S10 S11 S7 S17 S8 S3 S30'
I want to perform a SELECT check if the database field ZIP is in the string. I have used CHARINDEX as follows
charindex(uzip,'S10 S11 S7 S17 S8 S3 S30') > 0
BUT the problem is if the database field ZIP is , say S1 then it still finds it in the string because S10 in there which is obvioulsy incorrect
any help would be much appreciated
Thanks
I am pretty new to MSSQL and have a problem. The solution is probably very simple but I cant find it

I have a database field ZIP, I also have string with consists of a number of UK part postcodes eg
'S10 S11 S7 S17 S8 S3 S30'
I want to perform a SELECT check if the database field ZIP is in the string. I have used CHARINDEX as follows
charindex(uzip,'S10 S11 S7 S17 S8 S3 S30') > 0
BUT the problem is if the database field ZIP is , say S1 then it still finds it in the string because S10 in there which is obvioulsy incorrect
any help would be much appreciated
Thanks
•
•
Join Date: Feb 2008
Posts: 40
Reputation:
Solved Threads: 13
Change your Select check to:
charindex(' ' + uzip + ' ',' ' + 'S10 S11 S7 S17 S8 S3 S30' + ' ') > 0
This code will check 'S1' <> 'S10'
charindex(' ' + uzip + ' ',' ' + 'S10 S11 S7 S17 S8 S3 S30' + ' ') > 0
This code will check 'S1' <> 'S10'
Hence Wijaya
www.ex-Soft.tk
www.ex-Soft.tk
![]() |
Other Threads in the MS SQL Forum
- Previous Thread: Transfer values betqween two asp pages
- Next Thread: Query query!
| Thread Tools | Search this Thread |





