How do I wildcard a parameter search

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Geko747
    New Member
    • Feb 2018
    • 3

    How do I wildcard a parameter search

    Very new to all of this, I have a simple search that shows all invoice information for a client. I need to be able to search for part of the client name rather than an exact match. In Access i know a * will wildcard a search. How do I do it in SQL here is the code

    SELECT
    dimOrganisation .Name
    ,dimInstruction s.FILENO
    ,rpt_CIAReports _RawData.Invoic eID
    ,rpt_CIAReports _RawData.Alloca tionValue
    ,dimInvoiceEFI. InvoiceEFIID
    ,dimInvoice_EFI _Additional.INV OICEPRENAME
    ,dimInvoice_EFI _Additional.INV OICEADDRESSNAME
    ,dimInvoice_EFI _Additional.INV OICEADDRESSATTE NTION
    ,dimInvoice_EFI _Additional.INV OICEDATE
    ,dimInvoiceEFI. DRAFTNO
    FROM
    dimOrganisation
    INNER JOIN dimInstructions
    ON dimOrganisation .OrgID = dimInstructions .ORGID
    INNER JOIN rpt_CIAReports_ RawData
    ON dimInstructions .FILENO = rpt_CIAReports_ RawData.Instruc tion_FileNo
    INNER JOIN dimInvoiceEFI
    ON rpt_CIAReports_ RawData.Invoice ID = dimInvoiceEFI.I nvoiceID
    INNER JOIN dimInvoice_EFI_ Additional
    ON dimInvoiceEFI.I nvoiceEFIID = dimInvoice_EFI_ Additional.Invo iceEFIID
    WHERE
    dimInvoice_EFI_ Additional.INVO ICEADDRESSNAME = @INVOICEADDRESS NAMe
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    The wildcard in SQL Server is the percent symbol %

    Comment

    • Geko747
      New Member
      • Feb 2018
      • 3

      #3
      How would i include it within this though would it just be @invoiceaddress name%

      Comment

      • Rabbit
        Recognized Expert MVP
        • Jan 2007
        • 12517

        #4
        You do it the same way you would in Access SQL, but you replace the asterisk with a percent.

        On a side note, you seem to be using a variable @invoiceaddress name but you haven't defined it anywhere.

        Comment

        • Geko747
          New Member
          • Feb 2018
          • 3

          #5
          I have tried but just adding a % either side does not do anything. Could you show me an example in the code of where it would go. The query works fine it will find an exact match that i type into the parameter, but i need it to be a wildcard search as i am trying to find discrepancies in our data/

          Comment

          • Rabbit
            Recognized Expert MVP
            • Jan 2007
            • 12517

            #6
            It's a string so you have to treat it as such and append it to the search string.

            Code:
            field1 like @var1 + '%'
            You would have to do the same thing if you were using Access and using a variable.

            Comment

            Working...