只有函数和某些扩展存储过程才能从函数内部执行

The types of statements that are valid in a function include: 

DECLARE statements can be used to define data variables and cursors that are local to the function.


Assignments of values to objects local to the function, such as using SET to assign values to scalar and table local variables.


Cursor operations that reference local cursors that are declared, opened, closed, and deallocated in the function. FETCH statements that return data to the client are not allowed. Only FETCH statements that assign values to local variables using the INTO clause are allowed.


Control-of-flow statements.


SELECT statements containing select lists with expressions that assign values to variables that are local to the function.


UPDATE, INSERT, and DELETE statements modifying table variables that are local to the function.


EXECUTE statements calling an extended stored procedure. 
The number of times that a function specified in a query is actually executed can vary between execution plans built by the optimizer. An example is a function invoked by a subquery in a WHERE clause. The number of times the subquery and its function is executed can vary with different access paths chosen by the optimizer.

Built-in functions that can return different data on each call are not allowed in user-defined functions. The built-in functions not allowed in user-defined functions are:

@@CONNECTIONS      @@PACK_SENT          GETDATE 
@@CPU_BUSY         @@PACKET_ERRORS      GetUTCDate 
@@IDLE             @@TIMETICKS NEWID 
@@IO_BUSY          @@TOTAL_ERRORS RAND 
@@MAX_CONNECTIONS  @@TOTAL_READ TEXTPTR 
@@PACK_RECEIVED    @@TOTAL_WRITE   

转载于:https://www.cnblogs.com/cyg17173/p/7462041.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值