How to pass a comma separated list to a stored procedure?

If you're using Sybase 12.5 or earlier then you can't use functions. A workaround might be to populate a temporary table with the values and read them from there.


This is a little late, but I had this exact issue a while ago and I found a solution.

The trick is double quoting and then wrapping the whole string in quotes.

exec getSomething """John"",""Tom"",""Bob"",""Harry"""

Modify your proc to match the table entry to the string.

CREATE PROCEDURE getSomething @keyList varchar(4096)
AS
SELECT * FROM mytbl WHERE @keyList LIKE '%'+name+'%' 

I've had this in production since ASE 12.5; we're now on 15.0.3.

Tags:

Sql

Sap Ase