Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SHOWPLAN permission denied in database 'tempdb'. in sql server 2008

I have a query when I run the below query in Include Actual Execution Plan then it throws the following error :

Execution Result :

(1 row(s) affected)

(89 row(s) affected)

(1 row(s) affected) Msg 262, Level 14, State 4, Line 25 SHOWPLAN permission denied in database 'tempdb'.

Note : Before creating CLUSTERED INDEX on temptables it is working fine. after creating CLUSTERED INDEX it was showing the above error. how can I see the execution plan for the below query any suggestions.

like image 306
Kapil Avatar asked Jul 10 '14 07:07

Kapil


People also ask

What is Showplan Permission denied database?

As per the error message, you do not have permission to view the execution plans. To resolve this error, run the following T-SQL script from the admin user or SA account. Once you execute the GRANT SHOWPLAN, you can view the estimated and actual execution plan in SQL Server.

What is Showplan permission in SQL Server?

Users who have SHOWPLANpermission can view queries that are captured in Showplan output. These queries may contain sensitive information such as passwords. Therefore, it is recommended that you only grant these permissions to users who are authorized to view sensitive information. Comment.


2 Answers

Get an admin to run the following in the tempdb:

GRANT SHOWPLAN TO <UserName>
GO

where <UserName> is your username.

like image 128
SchmitzIT Avatar answered Sep 28 '22 00:09

SchmitzIT


In my case, I had with execute as 'dbo' specified on my procedure. Since the dbo user is specific to a database I doubt you can grant it the SHOWPLAN permission in tempdb. Instead, I removed the with execute as 'dbo' clause from the procedure and I was able to continue performance testing.

like image 45
Lee Houghton Avatar answered Sep 28 '22 00:09

Lee Houghton