i "use Windows autentication"
i execute this t-sql
use AdventureWorks
go
grant showplan to [SMI\elopezh]
the message is: Command(s) completed successfully.
i "included actual execution plan"
but i have this error
Msg 262, Level 14, State 4, Line 3
SHOWPLAN permission denied in database 'AdventureWorks'.
the t-sql code this
DECLARE @spexecutesqlStr NVARCHAR(1000) = 'EXEC [dbo].[GetCustomerInformation] @CustomerID = @CustID, @LastName = @Lname'
DECLARE @ParmDefinition NVARCHAR (500) = N'@CustID bigint, @LName varchar(30), @FName varchar(30), @MI char(1), @Email varchar(128), @RegionNo tinyint, @CustomerCode tinyint'
DECLARE @CustomerID BIGINT = 1
DECLARE @LastName VARCHAR(30) = 'Achong'
EXEC sp_executesql @spexecutesqlStr,
@ParmDefinition,
@CustID = @CustomerID,
@LName = @LastName,
@FName = null,
@MI = null,
@Email =null,
@RegionNo = null,
@CustomerCode= null
http://blog.sqlauthority.com/2010/01/05/sql-server-fix-error-262-showplan-permission-denied-in-database/
Obviously that "UserName" must be replaced with the windows login name you're using.