Eu estou fazendo a coisa certa...?
Eu tenho uma função que retorna dinheiro...
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
Estou apenas querendo saber se isso é possível ser convertido para iTVF?
Eu tentei fazer isso, mas recebi um erro:
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
ERRO:
Msg 4606, Level 16, State 1, Line 2 Privilégio concedido ou revogado EXECUTE não é compatível com o objeto.
Esta função é usada assim:
update table_name set interest = functionName(col1,col2...) where...
Desde já, obrigado!
As funções escalares exigem
EXECUTE
permissões, no entanto, quando você converte em uma função com valor de tabela, as permissões necessárias mudam paraSELECT
.Você deve agora
GRANT SELECT ON functionName TO another_user;
De BOL :
Precisa ser
GRANT SELECT ON functionName TO [another_user]
- com colchetes.Eu tentei usar:
Mas não funcionou, então, usei
EXECUTE
em vez deSELECT
, e funciona agora