2

此查询为我提供了在 SQL Server 上执行的命令的历史记录:

Select *
From
(
SELECT      deqs.last_execution_time AS [Time],
            dest.TEXT AS [Query]
FROM        sys.dm_exec_query_stats AS deqs
CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
) x

当我添加时,Where x.Query LIKE '%Insert%'我得到了不好的结果(我认为这是因为交叉连接):

Select *
From
(
    SELECT      deqs.last_execution_time AS [Time],
                dest.TEXT AS [Query]
    FROM        sys.dm_exec_query_stats AS deqs
    CROSS APPLY sys.dm_exec_sql_text(deqs.sql_handle) AS dest
) x
Where x.Query LIKE '%Insert%'

如何让交叉联接在 SQL Server 2008 R2 上正常工作?

4

1 回答 1

3

我不确定你的意思是:“坏结果”,但这对我有用:

SELECT deqs.last_execution_time AS [Time], dest.TEXT AS [Query]
FROM sys.dm_exec_query_stats AS deqs 
CROSS APPLY sys.dm_exec_sql_text(sql_handle) AS dest 
WHERE dest.TEXT LIKE '%Insert%'
于 2012-04-25T07:30:09.053 回答