如何转换CSV到T-SQL内的记录集? [英] HOW to convert CSV to record set inside T-SQL?

查看:147
本文介绍了如何转换CSV到T-SQL内的记录集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的存储过程中,我传递一个过滤器(使用WHERE Column IN子句)作为参数。参数的值以CSV形式给出。将此CSV转换为记录集的最佳方法是什么。

In my stored procedure I am passing a filter (using "WHERE Column IN" clause) as a parameter. The value of the parameter is given as CSV. What is the best method to convert this CSV in to a record set.

示例: -


SELECT *
FROM Employee
WHERE Name IN('John','Joe','Jerry','James')

,我需要将这些名称作为参数传递,这是一个CSV字符串,如

and I need to pass the names as a parameter which is a CSV string like


John,Joe,Jerry,James

推荐答案

查看Erland Sommarskog的文章。他有关于这种事情的不同方式的深入信息:

Take a look at Erland Sommarskog's articles. He has in-depth information on the different ways of doing this kind of thing:


SQL Server中的数组和列表

这篇关于如何转换CSV到T-SQL内的记录集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆