execute as - The server principal "sa" is not able to access the database "model" under the current security context -


i created stored procedure performs series of operations require special permissions, e.g. create database, restore database, etc. create stored procedure with

execute self 

...so runs sa. because want give sql user without permissions ability run these commands have defined.

but when run stored proc, get

the server principal "sa" not able access database "model" under current security context. 

how come sa can't access model database? ran code in stored proc on own, under sa, , ran fine.

read extending database impersonation using execute as before continue.

when impersonating principal using execute user statement, or within database-scoped module using execute clause, scope of impersonation restricted database default. means references objects outside scope of database return error.

you need use module signing. here example.


Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -