October 8, 2008 at 10:01 am
I am trying to catch a process wich is doing an insert and everytime it is running the server CPU spikes to 99% and won't allow connections with EM neither with terminal services. We workaround this problem and restart the server to 'fix' it, after the reboot I was able to see the process and detect the sentence is running.
So far so good, the problem is that I can only see the first 255 characthers of that sentence, and I need to see the whole code so I can send it to the developers so they can review it.
At first I used the DBCC BUFFERINPUT (SPID) to obtain the code but it is limited to the first 255 chars.
I found the next script:
DECLARE @handle binary(20)
SELECT @handle = sql_handle
FROM master..sysprocesses
WHERE spid = @@SPID
SELECT [text]
FROM ::fn_get_sql(@handle)
Unfortunately I am SOL since I can get over those 255 chars.
Is there a way to obtain the whole sentence for that process??
Thanks in advance
October 15, 2008 at 1:40 pm
I have not tried this with those statements, but have you considered changing the default column width? In option -> Results (query analyzer), you can change the characters per column (defaults to 255). Try setting this value higher and see if you get more characters back.
In fact... I am interested to know the result... 🙂
Hope that works for you.
Thanks
Herve Roggero
hroggero@pynlogic.com
MCDBA, MCSE, MCSD
SQL Server Database Proxy/Firewall and Auditing
October 15, 2008 at 6:58 pm
According to the following...
http://msdn.microsoft.com/en-us/library/aa258866(SQL.80).aspx
... the Test returned is of the data type TEXT which can contain up to 2 billion characters. But, the largest "column width" you can set query analyzer for is 8060 so you'll never see more than that.
Of course, if the code had a "purpose" header, you'd only need the first couple of hundred to find out which proc it was. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply