I am having trouble utilizing the EXECUTE AS clause. Here is the simple statement:
Execute as user = 'Common.com\bsmith'
--DBCC log(Actg, Type=2)
DBCC SQLPERF(LOGSPACE)
bsmith is the system administrator that has rights to both DBCC in connection with SQLPERF and the following statement:
DBCC log(Makeup, Type=2)
where the database is Makeup. My login (Common.com\dchrist)
does not have permission to do anything connected with the log file. The goal of this SQL is to allow dchrist to run items connected with Actg log files ONLY. I am logging into the server (EVR-NON-DB) as dchrist with my password.
Is there any way to do this or am I way off base. I have read several postings that explain EXECUTE AS and thought I understood how to use it. When I run:
Execute as user = 'Common.com\bsmith'
--DBCC log(Actg, Type=2)
DBCC SQLPERF(LOGSPACE)
I get the following error message:
Msg 15517, Level 16, State 1, Line 1
Cannot execute as the database principal because the principal "Common.com\bsmith" does not exist, this type of principal cannot be impersonated, or you do not have permission.
If anyone has any idea what I should do next I would really appreciate it. Thanks for all help in advance.
A couple of guesses. First, you probably need to use EXECUTE AS LOGIN =
Then look up "GRANT Server Principal Permissions". You probably have to give your login rights to IMPERSONATE the other login.
|||It sounds to me like you're referring to a LOGIN, not a USER. Try using 'LOGIN' instead of 'USER', or else work out which user maps to the login. A user is how a login accesses a database. Your login might access one database as dbo, another as bsmith, and a third as something else. Once you've got that sorted, let us know what the next error message says.
No comments:
Post a Comment