Deny connsect SQL from Stored Proecdure

Hello
I have a stored procedure the follwoing statement exists in the procedure

DENY CONNECT SQL TO AAAA CASCADE

The problem is i get the error message
Msg 4621, Level 16, State 10, Line 1
Permissions at the server scope can only be granted when the current database is master

I tried to preceed the stamenet
use master
but i got error message
a USE database statement is not allowed in a procedure, function or trigger.

So how can execute from Stored procedure
ali_alannahAsked:
Who is Participating?
 
Rainer JeschorCommented:
Hi,
you would have to convert the command in the to a string and run it  with a
execute Your string
see ref here
http://salviashish.wordpress.com/2009/07/06/sql-execute-with-character-string/

Dont forget to set the "use master" at the beginning of the string.
HTH
Rainer
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.