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
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