所以我有一个 Sybase 存储过程,它接受 1 个参数,该参数是一个逗号分隔的字符串列表,并在 IN() 子句中使用 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
编辑:我实际上发现这个页面对将数组传递给存储过程的各种方法有很好的参考