How do I pass a list as a parameter in a stored procedure?

前端 未结 7 1540
暖寄归人
暖寄归人 2020-12-02 22:15

Looking to pass a list of User IDs to return a list names. I have a plan to handle the outputed names (with a COALESCE something or other) but trying to find the best way to

7条回答
  •  孤城傲影
    2020-12-02 23:01

    Azure DB, Azure Data WH and from SQL Server 2016, you can use STRING_SPLIT to achieve a similar result to what was described by @sparrow.

    Recycling code from @sparrow

    WHERE user_id IN (SELECT value FROM STRING_SPLIT( @user_id_list, ',')
    

    Simple and effective way of accepting a list of values into a Stored Procedure

提交回复
热议问题