Solved

not able to get full text of query

Posted on 2013-01-18
2
686 Views
Last Modified: 2013-01-30
both the below statements are not bringing the full content of the query back..

(it brought 44k characters, but then truncated it) 43679 exactly..

SELECT DISTINCT cast(TEXT as varchar(max)) FROM sys.sysprocesses OUTER APPLY SYS.DM_EXEC_SQL_TEXT(0x01000E0036A22110001927D00300000000000000)

SELECT cast(TEXT as varchar(max)) FROM ::fn_get_sql(0x01000E0036A22110001927D00300000000000000)

for a query bigger than that, is it possible to capture it with the new DMVs or other SQL Server feature?

INPUTBUFFER also has that limitation, it seems like

thanks
0
Comment
Question by:25112
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 8

Expert Comment

by:venk_r
ID: 38795091
Is this on sql 2005 or 2008?
0
 
LVL 8

Accepted Solution

by:
venk_r earned 500 total points
ID: 38795184
You can use the below query to grab the sql .It will also give you other helpful informations  like login ,timetaken to run etc.

SELECT  p.session_id, start_time, p.status,p.cpu_time,p.total_elapsed_time, --original_login_name,
              (SELECT TOP 1 SUBSTRING(s2.text,statement_start_offset / 2+1 ,( (CASE WHEN statement_end_offset = -1
                   THEN (LEN(CONVERT(nvarchar(max),s2.text)) * 2)
                   ELSE statement_end_offset END)  - statement_start_offset) / 2+1))  AS sql_statement,host_name,program_name        FROM sys.dm_exec_requests p
      CROSS APPLY sys.dm_exec_sql_text(sql_handle)  s2 inner join sys.dm_exec_sessions s on s.session_id=p.session_id
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
How to leverage one TLS certificate to encrypt Microsoft SQL traffic and Remote Desktop Services, versus creating multiple tickets for the same server.
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question