A section of the output code itself SQL code

Source: Internet
Author: User
Tags join
declare @text nvarchar (max);  With TB as (select blocking_session_id, Session_id,db_name (database_id) as Dbname,text from master.sys.dm_exec_requests A CROSS APPLY master.sys.dm_exec_sql_text (a.sql_handle), tb1 as (select A.*,login_time,program_name,client_interface 
_name,login_name,cpu_time,memory_usage*8 as ' memory_usage (KB) ', total_scheduled_time,reads,writes,logical_reads From TB a INNER join master.sys.dm_exec_sessions b in a.session_id=b.session_id) select @text =text from TB1 a inner join
Master.sys.dm_exec_connections b on a.session_id=b.session_id print @text/* declare @text nvarchar (max);  With TB as (select blocking_session_id, Session_id,db_name (database_id) as Dbname,text from master.sys.dm_exec_requests A CROSS APPLY master.sys.dm_exec_sql_text (a.sql_handle), tb1 as (select A.*,login_time,program_name,client_interface 
_name,login_name,cpu_time,memory_usage*8 as ' memory_usage (KB) ', total_scheduled_time,reads,writes,logical_reads From TB a INNER join MASTER.SYS.DM_exec_sessions b on a.session_id=b.session_id) select @text =text from tb1 a inner join master.sys.dm_exec_connections b On a.session_id=b.session_id Print @text * *
A little shorter:
declare @text nvarchar (max);

Select @text =text from 
master.sys.dm_exec_requests  a
CROSS APPLY master.sys.dm_exec_sql_text (a.sql_ HANDLE)

print @text
/* declare @text nvarchar (max);

Select @text =text from 
master.sys.dm_exec_requests  a
CROSS APPLY master.sys.dm_exec_sql_text (a.sql_ HANDLE)

Print @text
* *
<

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.