I have following function which returns Table .
我有一个返回表的函数。
create Function FN(@Str varchar(30))
returns
@Names table(name varchar(25))
as
begin
while (charindex(',', @str) > 0)
begin
insert into @Names values(substring(@str, 1, charindex(',', @str) - 1))
set @str = substring(@str, charindex(',', @str) + 1, 100)
end
insert into @Names values(@str)
return
end
Could any one please explain me how to run this function.
谁能告诉我怎么运行这个函数吗?
2 个解决方案
#1
82
A TVF (table-valued function) is supposed to be SELECTed FROM. Try this:
应该从表值函数中选择一个TVF(表值函数)。试试这个:
select * from FN('myFunc')
#2
42
You can execute it just as you select a table using SELECT
clause. In addition you can provide parameters within parentheses.
您可以在使用select子句选择表时执行它。此外,还可以在括号内提供参数。
Try with below syntax:
试着使用下面的语法:
SELECT * FROM yourFunctionName(parameter1, parameter2)
#1
82
A TVF (table-valued function) is supposed to be SELECTed FROM. Try this:
应该从表值函数中选择一个TVF(表值函数)。试试这个:
select * from FN('myFunc')
#2
42
You can execute it just as you select a table using SELECT
clause. In addition you can provide parameters within parentheses.
您可以在使用select子句选择表时执行它。此外,还可以在括号内提供参数。
Try with below syntax:
试着使用下面的语法:
SELECT * FROM yourFunctionName(parameter1, parameter2)