sql server 创建内联表值函数

表值函数就是返回table 的函数使用它可以方便的进行查询的处理

创建的代码如下:

create FUNCTION returunclassfirstlist

 -- Add the parameters for the function here
 
)
RETURNS TABLE
AS
RETURN
(
 -- Add the SELECT statement with parameter references here
 select * from classfirst;
)

我们在使用创建的函数的时候如下:

select * from returunclassfirstlist();
select * from returunclassfirstlist() where CONVERT(int,classid)<300;

注意 第二个 sql 就是说对于创建的表值函数我们可以进行数据的筛选

具体的数据就不粘贴了。

原文地址:https://www.cnblogs.com/rongfengliang/p/3709223.html