Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 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.

  • #2
    New to the CF scene
    Join Date
    Mar 2009
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #3
    Senior Coder
    Join Date
    Apr 2003
    Location
    England
    Posts
    1,192
    Thanks
    5
    Thanked 13 Times in 13 Posts
    Please do not dig up threads from 2005.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •