Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/87.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何为此编写sql函数?_Sql_Sql Server 2008 - Fatal编程技术网

如何为此编写sql函数?

如何为此编写sql函数?,sql,sql-server-2008,Sql,Sql Server 2008,如果我将此字符串作为参数传递给SQL函数1,3,5,6 我需要在SQL函数中生成如下字符串 ('1','3','5','6') 使用SQL Server,我需要编写函数….尝试以下操作: select '('''''+REPLACE('1,3,5,6',',',''''',''''')+''''')' as Str 声明@Ids varchar(50)集合@Ids='1,2,3,5,4,6,7,98234' 从sometable中选择* Charindex(','+cast(tableid为

如果我将此字符串作为参数传递给SQL函数1,3,5,6

我需要在SQL函数中生成如下字符串

('1','3','5','6')
使用SQL Server,我需要编写函数….

尝试以下操作:

select '('''''+REPLACE('1,3,5,6',',',''''',''''')+''''')' as Str
声明@Ids varchar(50)集合@Ids='1,2,3,5,4,6,7,98234'

从sometable中选择*
Charindex(','+cast(tableid为varchar(8000))+,',@Ids)>0

您使用的是什么数据库管理系统?这是一个实现问题。你到底想完成什么?换句话说,你为什么需要那根绳子。我们也许能帮你跳过一步我有像1,3,5,6这样的字符串。。。。如果我传递字符串意味着使用sql函数,我需要像这样返回o/p……'(“1”、“3”、“5”、“6”)为什么?这个字符串在用什么?