如何在sql server中的存储过程中转换逗号分隔值

问题描述:

how to convert comma separated value in stored procedure in sql server







In

stored procedure



i有一个输入参数值,如1,2,3,5 ...





但我需要在过滤条件中查询WHERE子句('1','2','3','5',)





Plz可以帮助我做任何人


i have a input parameter values like this 1,2,3,5...


but i need to do in query in filter condition WHERE clause ('1','2','3','5',)


Plz can any one help me to do this

优先在这里提出这个问题,你试过在谷歌搜索一下吗?



我相信你需要

Prior to postig the question here, have you tried searching the same in Google?

I am sure you'll need
(1,2,3,5)



而不是


rather than

('1','2','3','5',)



最后的逗号没有任何意义,会导致语法错误。



几乎没有办法你可以做到这一点。

查看这些文章 -

[ ^ ]

将一个充满逗号分隔值的varchar传递给SQL Server IN函数 [ ^ ]



将逗号分隔(分隔)值作为参数传递给SQL Server中的存储过程
[ ^ ]



希望,它有帮助:)


The comma at the end doesn't make any sense and will result in syntax error.

There are few ways through which you can do this.
Check these articles-
Using comma separated value parameter strings in SQL IN clauses[^]
Passing a varchar full of comma delimited values to a SQL Server IN function[^]

Pass comma separated (delimited) values as Parameter to Stored Procedure in SQL Server
[^]

Hope, it helps :)


可以任何一个PLZ帮助我



can any one plz help me

i have a input parameter values like this 1,2,3,5...


but i need to do in query in filter condition WHERE clause ('1','2','3','5')