Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/sql-server/22.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 - Fatal编程技术网

SQL将表值函数与表联接,其中表字段是函数输入

SQL将表值函数与表联接,其中表字段是函数输入,sql,sql-server,Sql,Sql Server,我有一个名为fn_SplitCommaSep的表值函数,它用逗号分隔一个文本字段(从'a,b,c'到3行:a,b,c) 如何将表列作为输入,将其连接到表 为此,假设表MyTable有两列,Id和TextWithCommas,表值函数fn_SplitCommaSep生成一个名为TextWithoutComma的列 像这样的东西 select fs.TextWithoutComma from fn_SplitCommaSep(select mt.TextWithCommas from MyTab

我有一个名为fn_SplitCommaSep的表值函数,它用逗号分隔一个文本字段(从'a,b,c'到3行:a,b,c)

如何将表列作为输入,将其连接到表

为此,假设表MyTable有两列,Id和TextWithCommas,表值函数fn_SplitCommaSep生成一个名为TextWithoutComma的列

像这样的东西

select fs.TextWithoutComma
  from fn_SplitCommaSep(select mt.TextWithCommas from MyTable) fs 


将逗号分隔的值存储在数据库中,请看

比如:

SELECT fs.TextWithoutComma, mt.Id 
FROM   MyTable mt 
    CROSS APPLY fn_SplitCommaSep(mt.TextWithCommas) AS fs

太好了,谢谢!谢谢你抽出时间。使用逗号sep值获取的点。。。Boyce Codd不会高兴的,最糟糕的解决方案是:-)我找了一整天。。。但它工作得很好。谢谢。谢谢。这真的很有用。可能是
SELECT fs.TextWithoutComma, mt.Id 
FROM   MyTable mt 
    CROSS APPLY fn_SplitCommaSep(mt.TextWithCommas) AS fs