달력

3

« 2024/3 »

  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
2010. 1. 29. 18:59

[DB] MSSQL 실행된 쿼리 조회하기... 그거/DB2010. 1. 29. 18:59


오라클의 archive를 조회하는 것 처럼.

MSSQL에서도 이미 실행된 쿼리들을 조회할 수 있답니다.


select
db_name(st.dbid) DBName
,qs.total_elapsed_time
,creation_time
,last_execution_time,text
from sys.dm_exec_query_stats qs cross apply sys.dm_exec_sql_text(qs.plan_handle)st
join sys.dm_exec_cached_plans cp on qs.plan_handle = cp.plan_handle
where creation_time >= '2010-01-01 00:00:00'
--and db_name(st.dbid) is not null and cp.objtype = 'proc' --조건: 종류
and text like '%delete%'
order by last_execution_time desc;

이렇게 하면 된답니다.

실행된 파라미터까지 정확히 나오지는 않는듯 합니다.....
@1 이런식으로 나오네요..

:
Posted by 뽀기