Storeprocedure fetching data only for one condition..

  • I used or in to the storeprocedure,

    It executed but not taking id's for all conditions,

    I mean to say,

    i have streamid in my transition table like

    %,519%

    %,519,%

    %519,%

    %519%'

    so i gave the condition

    where b.coursetypeid=@CourseId and b.degreeid=@DegreeId

    and b.streamgroupid LIKE '''%,'+@streamid+',%'''

    or b.streamgroupid LIKE +@streamid+',%'+''

    or b.streamgroupid LIKE ''+'%,''%'+@streamid+''

    or b.streamgroupid LIKE +@streamid+'%'

    but it showing the record of only LIKE +@streamid+'% condition... [Sad]

    Is there any problem in syntax of other one?????

    Thanks & Regards,
    Pallavi

  • Try With This Where Condition.....

    where b.coursetypeid=@CourseId and b.degreeid=@DegreeId

    and b.streamgroupid LIKE '%'+','+@streamid+','+'%'

    and b.streamgroupid LIKE @streamid+','+'%'

    and b.streamgroupid LIKE '%'+','+'%'+@streamid

    and b.streamgroupid LIKE @streamid+'%'

    end

  • Duplicate post, work in progress here.

    โ€œWrite the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.โ€ - Gail Shaw

    For fast, accurate and documented assistance in answering your questions, please read this article.
    Understanding and using APPLY, (I) and (II) Paul White
    Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden

  • Yes ,

    It's working..

    Thank you very much ๐Ÿ™‚

    Thanks & Regards,
    Pallavi

  • Which Where Condition u used ..Tell me...:-D

  • conditions were right but syntax of like condition was wrong thats why it was showing wrong data...

    but now it's working

    if any problem then i'l let you know..

    thanks for ur valuable time.

    Thanks & Regards,
    Pallavi

  • Yes Exactly....:-D

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply