Wilcard Searches (1 Viewer)

Ice Rhino

Registered User.
Local time
Today, 02:18
Joined
Jun 30, 2000
Messages
210
I have a number of functions that require the input of parameters in order to ultimatly create a report under Reporting Services by making use of a Stored Procedure.

All the functions etc work as does the stored procedure, but it only works if I specify data that I know exists e.g.

DECLARE @return_value int

EXEC @return_value = [dbo].[spWTRalldatareportsummary]

@dt_src_date = N'04/28/2006',

@chr_div = N'NE',

@vch_portfolio_no = 3,

@vch_prop_cat = N'core'

SELECT 'Return Value' = @return_value

GO

How can I set this so that it will wild card the value. For example rather than having to specify

@chr_div = N'NE', I could specify something like

@chr_div = N *, so it would show both NE and SW values in the result set.

Anybody point me in a direction here. I have tried % but that does not seem to work, I get a

Msg 102, Level 15, State 1, Line 7

Incorrect syntax near '%'.

Thank in Advance
 

Ice Rhino

Registered User.
Local time
Today, 02:18
Joined
Jun 30, 2000
Messages
210
Currently my WHERE statements look like this;

FROM src_terrier INNER JOIN
src_centre_list ON src_terrier.siteref = src_centre_list.Site_Ref AND src_terrier.Areacode = src_centre_list.Division INNER JOIN
src_div_mgr ON src_centre_list.Division = src_div_mgr.division INNER JOIN
src_portfolio_mgr ON src_centre_list.Portfolio_no = src_portfolio_mgr.portfolio_no

WHERE (src_terrier.datadate = @dt_src_date) AND
(src_terrier.Areacode = @chr_div) AND
(src_centre_list.Portfolio_no = @vch_portfolio_no) AND
(src_centre_list.propcat = @vch_prop_cat)

Regards
 

Ice Rhino

Registered User.
Local time
Today, 02:18
Joined
Jun 30, 2000
Messages
210
I have gone for this as the final solution to the problem.

WHERE (src_terrier.datadate = @dt_src_date) AND

(@chr_div is null or src_terrier.Areacode = @chr_div) AND

(@vch_portfolio_no is null or src_centre_list.Portfolio_no = @vch_portfolio_no) AND

(@vch_prop_cat is null or src_centre_list.propcat = @vch_prop_cat)

Regards
 

Users who are viewing this thread

Top Bottom