Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Multiple Values in Delimited String Criteria for Paramete 1

Status
Not open for further replies.

DixieDean

Programmer
Nov 28, 2005
19
GB
Please stop me from going insane.

I am but a humble, inexperienced developer, and I’m currently developing a web-based system, using SQL Server Express Edition 2005 as the back-end database application, and I have a parameterized stored procedure that I want to accept a parameter called NIString, which will be dynamically generated based on user selections in a list box holding Football Events.

This parameter will receive a string of values, all encased in single quotes and separated by commas (e.g.

SELECT FootyEventDate, FootyEvent
FROM FootyEventsCalendar
WHERE FootyEvent IN (‘FA Cup Final’, ‘European Champions League Final’)

Expressed as

CREATE PROCEDURE sp_FootyDates
@NIString nchar(2000)
AS
SELECT FootyEventDate, FootyEvent
FROM FootyEventsCalendar
WHERE FootyEvent IN (@NIString)
GO

EXECUTE sp_FootyDates
@NIString = (‘FA Cup Final’, ‘European Champions League Final’)
GO

)

I’m having real problems when there is more than one Football Event placed in the NIString parameter (I thinks it’s got something to do with the delimiter and single quotes around each item in the list).

Can anyone suggest a simple and easy-to-understand solution to this problem?

I’ve scanned the Internet for possible solutions, but most on offer seem to involve creating a table that will store delimited values which can be referenced via a join, and they are much too complex for my intermediate status.

I would be forever grateful if someone could provide an easy way to do this.

DixieDean
 
Take a look at this FAQ: faq183-5207



-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
gmmastros, thanks very much for pointing me to the solution. It works a dream.

If you're ever in Liverpool, let me know, 'coz I owe you a huge drink.

Many thanks and merry christmas.

DixieDean
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top