Sql-server – SQL Server 2012: stored procedures permissions

permissionssql-server-2012stored-procedures

Is it possible to control permissions on a single stored procedure level in SQL Server 2012? It seems that SQL Server Manager doesn't expose such functionality via GUI. Can somebody advice me how to view/set permission on a single stored procedure level?
In particular I'm interested in removing "Connect" right on one procedure for specified account while leaving Connect rights for this account on all the others procedures. Is it possible?

Best Answer

You just need to deny EXECUTE permissions on any object that you don't want the app login to see. Denying VIEW DEFINITION will only prevent the code of the object from being seen by that user. That is the point of VIEW DEFINITION: to allow users to run code that they can't see the code for. Denying EXECUTE on the object will removing it completely as far as that login is concerned.

DENY EXECUTE ON SchemaName.ProcName TO [AppLogin];

Once the DENY has been run, the following won't return anything for that login:

SELECT OBJECT_ID('SchemaName.ProcName');

SELECT *
FROM   sys.objects so
WHERE  so.name = 'ProcName';