-3
Id  vDivisionNo
1    1,9
2    9
3    1
4    9,1

i have using char index but not find value

select * from DivisionMst where CHARINDEX(',' + vLocationNo + ',', ','+ '9,14' + ',') > 0  

And Try this

select * from DivisionMst where CHARINDEX(',' + '9,14' + ',', ','+ vLocationNo + ',') > 0

But Not working please help me.

Gurwinder Singh
  • 38,557
  • 6
  • 51
  • 76

2 Answers2

0

use this below query to find the answer

SELECT        *
FROM          DivisionMst
WHERE        (vDivisionNo LIKE '%,%')
Wintergreen
  • 236
  • 1
  • 9
0

You should, if possible, normalize your database.
Read Is storing a delimited list in a database column really that bad?, where you will see a lot of reasons why the answer to this question is Absolutly yes!.

If, however, you can't change the database structure, you can use LIKE:

SELECT * 
FROM DivisionMst 
WHERE ',' + vLocationNo + ',' LIKE '%,'+ '9,14' + ',%'

btw, your sample data does not contain a column name vLocationNo, nor does it contain a value '9,14'.

Community
  • 1
  • 1
Zohar Peled
  • 79,642
  • 10
  • 69
  • 121