Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.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 server 如何对CTE创建的数据使用表值函数_Sql Server_Common Table Expression - Fatal编程技术网

Sql server 如何对CTE创建的数据使用表值函数

Sql server 如何对CTE创建的数据使用表值函数,sql-server,common-table-expression,Sql Server,Common Table Expression,我只是想使用一个表值函数,并用一个简单的CTE建立的数据对其进行测试,但是我无法弄清楚如何让表值函数“看到”CTE。我错过了什么 /* The below shows that I can SELECT the CSVField from my CTE CSVData */ WITH CSVData AS ( SELECT 'a,b,f,hello,yup' as CSVField ) SELECT CSVField FROM CSVData ; /* This Works and

我只是想使用一个表值函数,并用一个简单的CTE建立的数据对其进行测试,但是我无法弄清楚如何让表值函数“看到”CTE。我错过了什么

/* The below shows that I can SELECT the CSVField from my CTE CSVData */
WITH CSVData AS
(
    SELECT 'a,b,f,hello,yup' as CSVField
)
SELECT CSVField FROM CSVData
;


/* This Works and produces a table of the CSV Values */
SELECT * FROM dbo.Split('a,b,f,hello,yup', ',')


/* Does NOT Work: The below for whatever reason the TVF can't see the CTE as if it's not in Scope or for some other reason */
WITH CSVData AS
(
    SELECT 'a,b,f,hello,yup' as CSVField
)
SELECT c.* FROM dbo.Split(CSVData.CSVField, ',') c
;
表输出示例

你可以这样写

使用CSVData作为 选择“a、b、f、helloWorld、YesSir”作为CSVField 选择c* 从dbo.Split中选择CSVField FROM CSVData,,'c ;