1. Start your profiler and check it.
2. Check the process info for the server processes running.
3. In SQL Server 2008, you can opt Activity Monitor.
What else?????????
Here is another method using queries? If you got the spid then DBCC Inputbuffer command will provide you the last execution command of your user. Let's see how?????
Get the current session id
SELECT @@SPID
The output is, 51
Let's execute the below query now,
CREATE TABLE VENKAT_TABLE (Col1 int)
GO
DECLARE @i int;
SELECT @i = 0
BEGIN TRAN
SELECT @i = 0
WHILE (@i < i =" @i">
Now, open another session or connection, and execute the command
DBCC INPUTBUFFER (51);
You will get the last statement executed by the particular session user.

create table #tmpDBCCinputbuffer ([Event Type] nvarchar(512), [Parameters] int, [Event Info] nvarchar(512))
insert into #tmpDBCCinputbuffer exec ('DBCC INPUTBUFFER(51)')
select [Event Info] from #tmpDBCCinputbuffer
It's nothing but the in-house or profiler query itself. The above statements were used to fetch the latest statements of your server processes.
Cheers,
Venkatesan Prabu .J
No comments:
Post a Comment