views:

209

answers:

1

What is the MySQL equivalent statement of DBCC INPUTBUFFER(@@SPID), which lists the sql statement for current connection or specified connection?

+3  A: 

Use SHOW PROFILES to see a list of the most recent statements sent to MySQL:

SHOW PROFILES;

If you want/need to see currently running queries, use SHOW PROCESSLIST:

SHOW FULL PROCESSLIST;

The FULL keyword means the list will include queries from all clients, not just the one you are running the command on.

OMG Ponies
beacuse i want sql statement for audot purpose.if i can get it from trigger then i will be fine.
Paresh
The FULL keyword means the list will include queries from all clients, not just the one you are running the command on.----- So how can we get for only current process?
Paresh
What do you mean by "current process"? If the query has finished executing, use `SHOW PROFILES`. If it is still running, use `SHOW PROCESSLIST`. There are links to the documentation.
OMG Ponies
Thanks BuddyRegards,paresh (paresh-sqldba.blogspot.com)
Paresh