This oen really has me puzzled. I have this code in a stored proc :
BEGIN
DECLARE @BadPattern2 CHAR(10)
DECLARE @BadPattern3 VARCHAR(10)
SELECT @BadPattern2 = '713,'
SET @BadPattern3 = '713'
SELECT ItemExplanationCodes, @BadPattern2 AS BadPattern
FROM BillItemXML
WHERE CHARINDEX( @BadPattern2, ItemExplanationCodes ) != 0
END
This returns no rows.
The funny thing is that if I use @BadPattern3, I find the rows I want. It's as though including the comma prevents CHARINDEX from working ... I don't know why that should be ?
Does anyone know why this is happening ? I'd appreciate help !
Thanks.
BEGIN
DECLARE @BadPattern2 CHAR(10)
DECLARE @BadPattern3 VARCHAR(10)
SELECT @BadPattern2 = '713,'
SET @BadPattern3 = '713'
SELECT ItemExplanationCodes, @BadPattern2 AS BadPattern
FROM BillItemXML
WHERE CHARINDEX( @BadPattern2, ItemExplanationCodes ) != 0
END
This returns no rows.
The funny thing is that if I use @BadPattern3, I find the rows I want. It's as though including the comma prevents CHARINDEX from working ... I don't know why that should be ?
Does anyone know why this is happening ? I'd appreciate help !
Thanks.