I'm logged into a SQL Server 2005 database as a non-sa user, 'bhk', that is a member of the 'public' server role only. The following code tries to execute within a stored procedure called by user 'bhk'. This line of code...
TRUNCATE TABLE #Table1
DBCC CHECKIDENT('#Table1', RESEED, @SequenceNumber) WITH NO_INFOMSGS
causes this error...
User 'guest' does not have permission to run DBCC CHECKIDENT for object
'#Table1__00000000007F'.
I'm aware of the permissions required to run DBCC CHECKIDENT...
*Caller must own the table, or be a member of the sysadmin fixed server role, the db_owner fixed database role, or the db_ddladmin fixed database role.*
So I have two questions:
- Since 'bhk' is calling a stored procedure that creates a temporary table, shouldn't 'bhk' be the owner and be allowed to run DBCC CHECKIDENT?
- Why does the error message return that user 'guest' doesn't have permission? To my knowledge, I'm not logged in as 'guest'.
Any help would be greatly appreciated.