April 13, 2011 at 8:40 am
Hello,
I am trying to recreate an Access function that can be slow at times with stored procedure that can be called from a c# program. What the stored procedure needs to do is take multiple values from a text box and give me the correct output. For instance:
Last Name (contains)
smit
First Name (contains)
joh,jon,j.
What I have written so far is:
CREATE PROCEDURE dbo.qName
@LastName nvarchar(50) = Null,
@FirstName nvarchar(50) = Null,
@MiddleName nvarchar(50) = Null
AS
BEGIN
SET NOCOUNT ON;
SELECT *
FROM dbo.defendants_ALL
WHERE (combined_name LIKE ISNull('%' + @LastName + '%', '')) AND (combined_name LIKE ISNull('%' + @FirstName + '%', ''))
END
GO
and to run it for example:
USE new_judgment_system;
GO
EXECUTE dbo.qName @FirstName = N'joh', @LastName = N'smit';
GO
This works for 1 value for a parameter but I need to be able to run a SP that will contain all of the comma separated strings joh,jon,j. .
Can this be done in TSQL and if so can someone point me in the right direction? I know on the c# side I can use arrays and run a separate SP for each value but that actually takes much longer than what is currently written in VBA. Any help would be great.
Thank you
April 13, 2011 at 10:00 am
Found my answer!
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply