Get last sql query for all open connections
up vote
2
down vote
favorite
In SQL 2008 R2, how can you query the database for all spids that are open and from that get the last sql query they made?
sql-server-2008
add a comment |
up vote
2
down vote
favorite
In SQL 2008 R2, how can you query the database for all spids that are open and from that get the last sql query they made?
sql-server-2008
add a comment |
up vote
2
down vote
favorite
up vote
2
down vote
favorite
In SQL 2008 R2, how can you query the database for all spids that are open and from that get the last sql query they made?
sql-server-2008
In SQL 2008 R2, how can you query the database for all spids that are open and from that get the last sql query they made?
sql-server-2008
sql-server-2008
asked Jul 22 '11 at 11:19
ilivewithian
12.1k1676149
12.1k1676149
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
up vote
3
down vote
accepted
The basic form is this using DMVs
SELECT
*
FROM
sys.dm_exec_requests er
CROSS APPLY
sys.dm_exec_sql_text(er.sql_handle) AS t
These can be refined or filtered as needed, for example like this link: https://sqlblog.org/2008/07/01/sys-dm_exec_requests
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
accepted
The basic form is this using DMVs
SELECT
*
FROM
sys.dm_exec_requests er
CROSS APPLY
sys.dm_exec_sql_text(er.sql_handle) AS t
These can be refined or filtered as needed, for example like this link: https://sqlblog.org/2008/07/01/sys-dm_exec_requests
add a comment |
up vote
3
down vote
accepted
The basic form is this using DMVs
SELECT
*
FROM
sys.dm_exec_requests er
CROSS APPLY
sys.dm_exec_sql_text(er.sql_handle) AS t
These can be refined or filtered as needed, for example like this link: https://sqlblog.org/2008/07/01/sys-dm_exec_requests
add a comment |
up vote
3
down vote
accepted
up vote
3
down vote
accepted
The basic form is this using DMVs
SELECT
*
FROM
sys.dm_exec_requests er
CROSS APPLY
sys.dm_exec_sql_text(er.sql_handle) AS t
These can be refined or filtered as needed, for example like this link: https://sqlblog.org/2008/07/01/sys-dm_exec_requests
The basic form is this using DMVs
SELECT
*
FROM
sys.dm_exec_requests er
CROSS APPLY
sys.dm_exec_sql_text(er.sql_handle) AS t
These can be refined or filtered as needed, for example like this link: https://sqlblog.org/2008/07/01/sys-dm_exec_requests
edited Nov 9 at 22:31
Aaron Bertrand
206k27360401
206k27360401
answered Jul 22 '11 at 11:44
gbn
337k56480573
337k56480573
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f6789214%2fget-last-sql-query-for-all-open-connections%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown