Web Analytics Made Easy -
StatCounter returning multiple records with charindex - CodingForum

Announcement

Collapse
No announcement yet.

returning multiple records with charindex

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • returning multiple records with charindex

    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 using
    Code:
    SELECT 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.
    My tech/code blog

  • #2
    alternet solution

    I understood that all you want to is to fetch data.
    In sql 2005 it would be like this

    create procedure Find
    @search varchar(50)
    AS
    SELECT b, c FROM t WHERE (CharIndex( Cast(@search As Binary(4)) , a) % 10 = 4)
    that should do it dude

    Comment


    • #3
      Please do not dig up threads from 2005.
      My tech/code blog

      Comment

      Working...
      X