Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

EXECTE AS Permissions problem while trunacating table

Posted on 2009-05-19
2
Medium Priority
?
217 Views
Last Modified: 2012-05-07
I have a stored procedure, called from Access as a pass through query, that works for me but not for the users. The error message is:

'Cannot find the object "AgrRelations_Materials" because it does not exist or you do not have permissions.'

This procedure truncates then recreates some lookup tables. After a bit of Googling I have come to the conclusion that the problem is due to the TRUNCATE statements which, apparently, do not follow the normal pattern of ownership chaining (which I had never heard of until today). I have kind of confirmed this by replacing the TRUNCATE statements with delete statements, and the users can now use the procedure.

However, I wanted to use TRUNCATE as it is faster, so I tried wrapping an EXECUTE AS then REVERT around the TRUNCATE statements:

EXECUTE AS USER = 'dbo'
TRUNCATE TABLE Relations.AgrRelations_Materials
REVERT

Although this still works for me the users get the following:
Cannot execute as the database principal because principal dbo does not exist, this type of principal cannot be impersonated, or you do not have the permission.

dbo is a user in this database and owns most of the schemas, including the Relations schema that these tables are in.
More Googling and I am stuck. The database has not been restored and does not meet the criteria in kb/913423.

Any help gratefully received: Im a relative newbie and  I expect this will come up a lot.
0
Comment
Question by:Blim2
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 26

Accepted Solution

by:
tigin44 earned 750 total points
ID: 24420378
0
 

Author Comment

by:Blim2
ID: 24420442
The solution recommended is to create a table truncating procedure with EXECUTE AS SELF. I could then call this from my original procedure and maybe even parameterise it to accept table names. That sounds great but  what happens if I leave the company. Won't EXECUTE AS SELF stamp my credentials on the procedure and won't the procedure therefore stop working if my Windows logon is removed?
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question