SQL将表值函数与表联接,其中表字段是函数输入
我有一个名为fn_SplitCommaSep的表值函数,它用逗号分隔一个文本字段(从'a,b,c'到3行:a,b,c) 如何将表列作为输入,将其连接到表 为此,假设表MyTable有两列,Id和TextWithCommas,表值函数fn_SplitCommaSep生成一个名为TextWithoutComma的列 像这样的东西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
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