Lo estoy haciendo bien...?
Tengo una función que devuelve dinero ...
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
¿Me pregunto si esto se puede convertir a iTVF?
Intenté hacer esto pero recibí un error:
CREATE FUNCTION functionName ( @a_principal money, @a_from_date
datetime, @a_to_date datetime, @a_rate float )
RETURNS TABLE AS
RETURN SELECT returnMoney = computation_here
GO
Grant execute on functionName to another_user Go
ERROR:
Msg 4606, Nivel 16, Estado 1, Línea 2 Privilegio otorgado o revocado EJECUTAR no es compatible con el objeto.
Esta función se usa así:
update table_name set interest = functionName(col1,col2...) where...
¡Gracias por adelantado!
sql-server
functions
Jack Frost
fuente
fuente

Respuestas:
Las funciones escalares requieren
EXECUTEpermisos, sin embargo, cuando se convierte en una función con valores de tabla, los permisos requeridos cambian aSELECT.Debes ahora
GRANT SELECT ON functionName TO another_user;De BOL :
fuente
grant select on functionName to [DOMAINNAME\username];Tiene que ser
GRANT SELECT ON functionName TO [another_user], con paréntesis.fuente
Traté de usar:
Pero no funcionó, entonces, usé en
EXECUTElugar deSELECT, y funciona ahorafuente
grant executeuna función SQL siempre arrojará un error.