Results 1 to 2 of 2
  1. #1
    Join Date
    Feb 2004
    Location
    Alpine Califormia
    Posts
    1,789

    Unanswered: incorporating wildcards in a report so users can search comments

    Hello I need to create a stored procedure and incorporate it into a report where the users can look up certain values in comment fields. This is what I have so far but I am getting errors, maybe I'm tired and I'm not seeing what the issue is can anyone help please


    Code:
    CREATE PROCEDURE 
     [dbo].[SearchAccomplishments]
     @Enter_Accomplishments text =null,
     @Beginning_CompletionDate datetime = null,
     @End_CompletionDate datetime = null
    
    
    AS
    
       IF patindex( '*', @Enter_Accomplishments ) > 0 
    
          BEGIN
    
             SET @Enter_Accomplishments = replace( @Enter_Accomplishments, '*', '%' )
              
              SELECT     A.CompletionDate, A.Accomplishments, A.accomplishID, A.Participant
     FROM         Accomplishments_tbl A
    
      WHERE (Accomplishments LIKE @Enter_Accomplishments)
        AND (Accomplishments LIKE @Enter_Accomplishments)
      AND (@Beginning_CompletionDate    IS NULL OR CompletionDate >= @Beginning_CompletionDate)
      and (@End_CompletionDate IS NULL OR CompletionDate <= @End_CompletionDate)
    
          END 
    
       ELSE
    
          BEGIN
    
            IF patindex( '*', @Enter_Accomplishments ) > 0 
        SET @Enter_Accomplishments = replace( @Enter_Accomplishments, '*', '%' ) 
      SELECT     A.CompletionDate, A.Accomplishments, A.accomplishID, A.Participant
     FROM         Accomplishments_tbl A
    
     WHERE (Accomplishments LIKE @Enter_Accomplishments)
        AND (Accomplishments LIKE @Enter_Accomplishments)
      AND (@Beginning_CompletionDate    IS NULL OR CompletionDate >= @Beginning_CompletionDate)
      and (@End_CompletionDate IS NULL OR CompletionDate <= @End_CompletionDate)
    
    
      
     ORDER BY CompletionDate
    
     END

  2. #2
    Join Date
    Nov 2004
    Location
    on the wrong server
    Posts
    8,835
    Provided Answers: 6
    Ok. I will bite. It parses. What is the error?
    “If one brings so much courage to this world the world has to kill them or break them, so of course it kills them. The world breaks every one and afterward many are strong at the broken places. But those that will not break it kills. It kills the very good and the very gentle and the very brave impartially. If you are none of these you can be sure it will kill you too but there will be no special hurry.” Earnest Hemingway, A Farewell To Arms.

Posting Permissions

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