所以我有一个Sybase存储过程,它采用一个逗号分隔的字符串列表的参数,并在IN()子句中运行一个查询:
CREATE PROCEDURE getSomething @keyList varchar(4096) AS SELECT * FROM mytbl WHERE name IN (@keyList)
如何在列表中调用超过1个值的存储过程?
到目前为止我已经尝试过了
exec getSomething 'John' -- works but only 1 value exec getSomething 'John','Tom' -- doesn't work - expects two variables exec getSomething "'John','Tom'" -- doesn't work - doesn't find anything exec getSomething '"John","Tom"' -- doesn't work - doesn't find anything exec getSomething '\'John\',\'Tom\'' -- doesn't work - Syntax error
编辑:我实际上发现这个page有一个很好的参考,将各种方式的数组放到一个sproc