[英]What's wrong with this T-SQL?
What's wrong with this T-SQL : 这个T-SQL有什么问题:
DECLARE @temp TABLE(ID INT IDENTITY,[Value] VARCHAR(100))
SET @temp = dbo.[fnCSVToTable](',2,3')
I don't think you can assign to the table variable like that (unless it is a new thing in SQL 2008). 我认为您不能像这样分配给表变量(除非它在SQL 2008中是新事物)。
At least for SQL2005 you would need to do the following. 至少对于SQL2005,您需要执行以下操作。
DECLARE @temp TABLE(ID INT IDENTITY,[Value] VARCHAR(100))
INSERT INTO @temp
SElECT [value]
FROM dbo.[fnCSVToTable](',2,3')
From the docs for SET
( SQL 2008 ; SQL 2005 ) (my emphasis): 从SET
的文档( SQL 2008 ; SQL 2005 )(我的重点):
@ local_variable
Is the name of a variable of any type except cursor, text, ntext, image, or table . 是除游标,text,ntext,image 或table外的任何类型的变量的名称。
To populate a table variable, use 要填充表变量,请使用
INSERT @table_variable
SELECT columns
FROM dbo.fnTableValuedFunction
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.