By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,963 Members | 2,016 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,963 IT Pros & Developers. It's quick & easy.

How do I wildcard a parameter search

P: 3
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
,dimInstructions.FILENO
,rpt_CIAReports_RawData.InvoiceID
,rpt_CIAReports_RawData.AllocationValue
,dimInvoiceEFI.InvoiceEFIID
,dimInvoice_EFI_Additional.INVOICEPRENAME
,dimInvoice_EFI_Additional.INVOICEADDRESSNAME
,dimInvoice_EFI_Additional.INVOICEADDRESSATTENTION
,dimInvoice_EFI_Additional.INVOICEDATE
,dimInvoiceEFI.DRAFTNO
FROM
dimOrganisation
INNER JOIN dimInstructions
ON dimOrganisation.OrgID = dimInstructions.ORGID
INNER JOIN rpt_CIAReports_RawData
ON dimInstructions.FILENO = rpt_CIAReports_RawData.Instruction_FileNo
INNER JOIN dimInvoiceEFI
ON rpt_CIAReports_RawData.InvoiceID = dimInvoiceEFI.InvoiceID
INNER JOIN dimInvoice_EFI_Additional
ON dimInvoiceEFI.InvoiceEFIID = dimInvoice_EFI_Additional.InvoiceEFIID
WHERE
dimInvoice_EFI_Additional.INVOICEADDRESSNAME = @INVOICEADDRESSNAMe
Feb 23 '18 #1
Share this Question
Share on Google+
5 Replies


Rabbit
Expert Mod 10K+
P: 12,430
The wildcard in SQL Server is the percent symbol %
Feb 23 '18 #2

P: 3
How would i include it within this though would it just be @invoiceaddressname%
Feb 27 '18 #3

Rabbit
Expert Mod 10K+
P: 12,430
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 @invoiceaddressname but you haven't defined it anywhere.
Feb 27 '18 #4

P: 3
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/
Feb 28 '18 #5

Rabbit
Expert Mod 10K+
P: 12,430
It's a string so you have to treat it as such and append it to the search string.

Expand|Select|Wrap|Line Numbers
  1. field1 like @var1 + '%'
You would have to do the same thing if you were using Access and using a variable.
Feb 28 '18 #6

Post your reply

Sign in to post your reply or Sign up for a free account.