[thelist] [SQL] using a char string as a list
Sean G.
ethanol at mathlab.sunysb.edu
Thu Jun 6 23:56:01 CDT 2002
Howdy,
Can a list be passed into a stored procedure as a char or varchar? I'm
working with MS-SQL 2000. I found a gaggle of related posts in the groups
on google, but they mainly focused on having quotes and commas recognized as
being part of the variable and not delimiters.
As far as I can tell, the variable is okay. When I print and cut-n-paste
the value into a query, I get the expected results. However calling the
variable in the query always returns 0 matches.
Any ideas?
Thanks,
Sean G.
snipets:
DECLARE @UnitList AS varchar(50)
SET @UnitList = '"AME","RE"'
select count(UnitKey) as blah from vUnitSort
where UnitAbbrev in (@UnitList)
print @UnitList
returns:
blah
----
0
"AME","RE"
where as:
select count(UnitKey) as blah from vUnitSort
where UnitAbbrev in ("AME","RE")
returns:
blah
----
1453
More information about the thelist
mailing list