I am trying to get information for the columns of the following query:
select (select text from sys.dm_exec_sql_text(q.sql_handle)) as [Script Text], DB_NAME(dbid) as [Database], program_name, nt_username, loginame, last_execution_time from sys.dm_exec_query_stats q full join sys.sysprocesses p on q.sql_handle = p.sql_handle where spid <> @@spid order by last_execution_time desc
But the columns 'Script Text' and 'last_execution_time' have all NULL values. Could you kindly say why this happens and how I can get it to give the desired values? I appreciate your help.