0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

SQL Serverで過去に実行したSQLを調べたい

Posted at

1. はじめに

  • SQL Server で実行したSQLを調査するため必要な権限を付与したい
  • 過去実行したSQLを取得したい

2. 権限の付与

  • 下記コマンドで管理者からユーザーに権限を付与する
GRANT VIEW SERVER STATE TO <ユーザー名> WITH GRANT OPTION;

3. 過去に実行したSQL取得

  • 下記以外にも色々な情報を取得できるので、詳細は参考文献を確認してください
SELECT st.text FROM sys.dm_exec_query_stats qs CROSS APPLY sys.dm_exec_sql_text(qs.sql_handle) st;

4. 参考文献

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?