create function select_salary ()
returns table
as
return
(
select * from staff where salary>1000
)
这样的函数可以用;
但是当加上begin和end后就不可以了。为什么呢?
create function select_salary ()
returns table
as
begin
return
(
select * from staff where salary>1000
)
end
returns table
as
return
(
select * from staff where salary>1000
)
这样的函数可以用;
但是当加上begin和end后就不可以了。为什么呢?
create function select_salary ()
returns table
as
begin
return
(
select * from staff where salary>1000
)
end
解决方案 »
- 数据库安装的问题
- 求高人给个数据库查询分页的代码.谢谢了
- 急!想用原来的数据库,可服务器上已有同名数据库,怎么办?
- 一个很难的sql
- 数据库压缩后速度奇慢,求优化方案
- 关于 group by
- 小女子求教:编写存储过程时,带有一个参数,是用来提供给not in作为限制条件,但发现不管用,请见内!在线等
- 有感: 高分(2000)求教:进货管理、库存管理、销售管理的数据库设计的要点!
- 怎样查看某个表所占用的空间大小?
- 这个sql怎么写,菜鸟勿喷..求大牛带..
- 数据库中的连接字符串问题--50分了
- 在vc程序里-----------------[DBNETLIB][ConnectionOpen (Connect()).]SQL Server 不存在或拒绝访问(xp系统)
( [ { @parameter_name [AS] scalar_parameter_data_type [ = default ] } [ ,...n ] ] ) RETURNS TABLE [ WITH < function_option > [ [,] ...n ] ] [ AS ]RETURN [ ( ] select-stmt [ ) ]
---
这是标准内嵌表值函数写法,加了begin就出错哦
CREATE FUNCTION <Inline_Function_Name, sysname, FunctionName>
(
-- Add the parameters for the function here
<@param1, sysname, @p1> <Data_Type_For_Param1, , int>,
<@param2, sysname, @p2> <Data_Type_For_Param2, , char>
)
RETURNS TABLE
AS
RETURN
(
-- Add the SELECT statement with parameter references here
SELECT 0
)
GO
意义当然大。当然静态select的意义或许不大,简单的select意义意义或许不大。我们往往将复杂的结果集创建成视图,以方便使用,但视图不支持参数查询,而内嵌表函数就可以支持参数查询,这就是意义所在。