ghell
07-29-2005, 10:58 AM
i am trying to search a string for another string (actually its all binary but that doesnt make any diff) and then return 1 record for every occurance it finds
im guessing the way to do this is loop through using charindexes to start where the last 1 was found but i cant work out how to do this in a stored procedure (as some of you may have guessed by now im pants at this ;) )
for example every time 0x0F34 is found in field a, i it should return a record with fields b and c in it (i dont need to know where it was found i just need 1 record for every occurance even though they will all contain the same data)
at the moment i am usingSELECT b, c FROM t WHERE (CharIndex( Cast(422548 As Binary(4)) , a) % 10 = 4)which works great but it only returns a record for the first instance found.
im guessing the way to do this is loop through using charindexes to start where the last 1 was found but i cant work out how to do this in a stored procedure (as some of you may have guessed by now im pants at this ;) )
for example every time 0x0F34 is found in field a, i it should return a record with fields b and c in it (i dont need to know where it was found i just need 1 record for every occurance even though they will all contain the same data)
at the moment i am usingSELECT b, c FROM t WHERE (CharIndex( Cast(422548 As Binary(4)) , a) % 10 = 4)which works great but it only returns a record for the first instance found.