SQL SERVER 用户自定义函数使用限制

 

UDFs (User Defined Functions) are a great feature in every RDBMS. We have covered their usefulness before in our blog posts. Based on some of the questions that we have been getting, we thought about writing a blog post that just talks about the limitations of the UDFs in SQL Server, so here goes:

1) The TRY…CATCH block cannot be used in a UDF. Infact, other error handling modes: @@ERROR or RAISERROR are not supported either.

Try-catch语句不能够在函数使用,实际上包括错误处理模式:@@ERROR 或 RAISERROR 也都不支持

2) Non deterministic functions like getdate() cannot be used with a UDF. Though there are workarounds for it.  And it is allowed in SQL Server 2008.

不确定性的函数,如getdate()不能在函数内调用;虽然有变通的方法,并且在MS2008内有支持。

3) A UDF (any of the three variations – scalar, inline or multi-statement) cannot be used to return multiple result sets.

函数不能返回多个结果集

4) UDFs cannot call stored procedures. They can, however, call extended stored procedures.

函数不能调用存储过程,除扩展的存储过程外

5) UDFs cannot make use of dynamic SQL or temporary tables within the code. Table variables are allowed though.

不能应用动态语句及临时表(局部或者全局都不行),但可以使用表变量。(所以想通过函数实现动态执行SQL语句就不用想了。)

6) Any type of SET commands are not allowed with a UDF.

任何SET命令都不允许在函数内操作。

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值