SP_2018 .
asked on
Execution plan
Hi,
I am trying to execute a dmv query with login credentials without sysadmin rights.
I have given GRANT VIEW SERVER STATE TO [username] rights to this user
Below is the query trying to execute.
SELECT TOP 100 SUBSTRING(qt.TEXT, (qs.statement_start_offset /2)+1,
((CASE qs.statement_end_offset
WHEN -1 THEN DATALENGTH(qt.TEXT)
ELSE qs.statement_end_offset
END - qs.statement_start_offset) /2)+1),
qs.execution_count,
qs.total_logical_reads, qs.last_logical_reads,
qs.total_logical_writes, qs.last_logical_writes,
qs.total_worker_time,
qs.last_worker_time,
qs.total_elapsed_time/1000 000 total_elapsed_time_in_S,
qs.last_elapsed_time/10000 00 last_elapsed_time_in_S,
qs.last_execution_time,
qp.query_plan,
sp.hostname,
sp.program_name,
sp.nt_username,
sp.loginame
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(qs.sq l_handle) qt
CROSS APPLY sys.sysprocesses sp
CROSS APPLY sys.dm_exec_query_plan(qs. plan_handl e) qp
ORDER BY qs.total_worker_time DESC .
I am able to execute the dmv query , however the execution plan is not
visible in the graphical format but can only be seen in xml form.
Kindly advise how this can be achieved.
Thanks,
I am trying to execute a dmv query with login credentials without sysadmin rights.
I have given GRANT VIEW SERVER STATE TO [username] rights to this user
Below is the query trying to execute.
SELECT TOP 100 SUBSTRING(qt.TEXT, (qs.statement_start_offset
((CASE qs.statement_end_offset
WHEN -1 THEN DATALENGTH(qt.TEXT)
ELSE qs.statement_end_offset
END - qs.statement_start_offset)
qs.execution_count,
qs.total_logical_reads, qs.last_logical_reads,
qs.total_logical_writes, qs.last_logical_writes,
qs.total_worker_time,
qs.last_worker_time,
qs.total_elapsed_time/1000
qs.last_elapsed_time/10000
qs.last_execution_time,
qp.query_plan,
sp.hostname,
sp.program_name,
sp.nt_username,
sp.loginame
FROM sys.dm_exec_query_stats qs
CROSS APPLY sys.dm_exec_sql_text(qs.sq
CROSS APPLY sys.sysprocesses sp
CROSS APPLY sys.dm_exec_query_plan(qs.
ORDER BY qs.total_worker_time DESC .
I am able to execute the dmv query , however the execution plan is not
visible in the graphical format but can only be seen in xml form.
Kindly advise how this can be achieved.
Thanks,
ASKER
Hi,
Thanks for your reply.
User has SHOWPLAN permissions for all databases but has not been given sysadmin rights
however when the above query is run with the user's login credentials, the execution plan is not visible in the graphical format but can only be seen in xml form.
When i run the same query with my login credentials which has sysadmin rights
i am able to view the execution plan in the graphical format.
Following permission have been granted to the user:
GRANT VIEW SERVER STATE TO [username] rights to this user(for viewing DMV queries)
GRANT SHOWPLAN to [username] (to view the execution plan)
Are their any specific permission which need to be given to the user to view
execution plan in graphical format and not in xml form .
Thanks.
Thanks for your reply.
User has SHOWPLAN permissions for all databases but has not been given sysadmin rights
however when the above query is run with the user's login credentials, the execution plan is not visible in the graphical format but can only be seen in xml form.
When i run the same query with my login credentials which has sysadmin rights
i am able to view the execution plan in the graphical format.
Following permission have been granted to the user:
GRANT VIEW SERVER STATE TO [username] rights to this user(for viewing DMV queries)
GRANT SHOWPLAN to [username] (to view the execution plan)
Are their any specific permission which need to be given to the user to view
execution plan in graphical format and not in xml form .
Thanks.
Which execution plan are you talking about: Estimated or Actual?
ASKER
Its Actual execution plan
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Did you resolve this problem and if so what was the solution?
Also read the following article also from SQL Server's BOL:
Showplan Security
http://msdn.microsoft.com/en-us/library/ms189602(v=sql.105).aspx