I have created a user defined function in .NET 2.0 and am able to successfully deploy it to my local SQL Server instance. However, I need to grant a specific user EXECUTE
permission on the function. I want this to be done in the CLR method itself so that I don't have to manually re-grant the permission every time I redeploy the UDF. Deploying the CLR function from Visual Studio generates this function in the database:
ALTER FUNCTION [dbo].[MyFunction](@input [nvarchar](max))
RETURNS [nvarchar](max) WITH EXECUTE AS CALLER
AS
EXTERNAL NAME [LibName].[UserDefinedFunctions].[MyFunction]
GO
Is there a way I can have it tack this on:
GRANT EXECUTE ON [dbo].[MyFunction] TO [wwwUser] AS [dbo]
Thanks.