January 10, 2003 at 4:26 pm
Very simple sProc:
-----------
CREATE PROCEDURE [dbo].[usp_SelectSecuritiesOfType]
@SecType varchar(100)
AS
SELECT * from tablename where columname IN (@SecType)
------------
As long as @SecType contains one value (ie 'foo') it works correctly.
WHen passing multiple items to search, I've tried the usual double single quote methodology without success.
How should the string that is passed to this sProc be constructed?
I've tried
"item1, item2"
"''item1'',''item2"
"'item1','item2'"
"'item1'',''item2'"
etc...
Apparently the IN function is expecting something different from the usually O'Malley handling?
January 10, 2003 at 4:52 pm
Tim, what you are ending up doing is something like this:
SELECT * from tablename where columname IN ( 'item1, item2' )
or something like this:
IN( '"item1, item2"' ) and so on.
You can achive the goal with the way you pass the parameter by using dinamic SQL:
SET @sql = 'SELECT * from tablename where columname IN (''' + @SecType + ''')'
sp_executesql( @sql )
You can also avoid using dinamic SQL. It will require more comprehensive code.
January 11, 2003 at 6:52 am
That works - thanks a lot
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply