Sql Server 获取数据库最近执行的操作
Posted 人生为卒
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Sql Server 获取数据库最近执行的操作相关的知识,希望对你有一定的参考价值。
select top 1000 s2.dbid, DB_NAME(s2.dbid) as [dbname], (select top 1 substring(s2.text,statement_start_offset/2+1, ((case when statement_end_offset=-1 then( len(convert(nvarchar(max),s2.text))*2) else statement_end_offset end)- statement_start_offset)/2+1) )as sqll, last_execution_time as [time] from sys.dm_exec_query_stats as s1 cross apply sys.dm_exec_sql_text(sql_handle) as s2 where s2.objectid is null order by last_execution_time desc SELECT TOP 1000 s2.dbid, DB_NAME(s2.dbid) AS [dbname], ( SELECT TOP 1 SUBSTRING ( s2. TEXT, statement_start_offset / 2 + 1, ( ( CASE WHEN statement_end_offset =- 1 THEN ( len( CONVERT (nvarchar(MAX), s2. TEXT) ) * 2 ) ELSE statement_end_offset END ) - statement_start_offset ) / 2 + 1 ) ) AS sqll, last_execution_time AS [time] FROM sys.dm_exec_query_stats AS s1 CROSS apply sys.dm_exec_sql_text (sql_handle) AS s2 WHERE s2.objectid IS NULL ORDER BY last_execution_time DESC
以上是关于Sql Server 获取数据库最近执行的操作的主要内容,如果未能解决你的问题,请参考以下文章
sql server 2008安装出错,试图执行未经授权的操作。