我做得对吗?
CREATE FUNCTION functionName( @a_principal money,@a_from_date datetime,@a_to_date datetime,@a_rate float ) RETURNS money AS BEGIN DECLARE @v_dint money set @v_dint = computation_here set @v_dint = round(@v_dint,2) RETURN @v_dint END GO Grant execute on functionName to another_user Go
我只是想知道这是否可以转换为iTVF?
CREATE FUNCTION functionName ( @a_principal money,@a_rate float ) RETURNS TABLE AS RETURN SELECT returnMoney = computation_here GO Grant execute on functionName to another_user Go
错误:
Msg 4606,Level 16,State 1,Line 2
Granted or revoked privilege EXECUTE is not compatible with object.
这个函数使用如下:
update table_name set interest = functionName(col1,col2...) where...
提前致谢!
解决方法
标量函数需要EXECUTE权限,但是当您转换为表值函数时,所需的权限将更改为SELECT.
您现在必须GRANT SELECT ON functionName TO another_user;
从BOL开始:
Users other than the owner must be granted EXECUTE permission on a function (if the function is scalar-valued) before they can use it in a Transact-sql statement. If the function is table-valued,the user must have SELECT permissions on the function before referencing it.
原文地址:https://www.jb51.cc/mssql/80393.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。