0

我遇到了 SQL 执行错误的问题。我正在尝试执行视图,但出现“执行超时已过期”错误。我正在运行的代码如下。我需要将其作为视图运行,因为这些表链接到自动更新的 dbo,并且我需要此视图与 MS Access 报告使用它时一样最新。(据我了解,视图不需要手动执行即可)

我试图更改所有超时位置,包括工具->选项、登录连接选项和注册表编辑器,但我仍然收到错误消息。

它在 30 秒后超时,那么我还能在哪里更改呢?这是否不起作用,因为我没有完整的“IT 管理员”权限(即使看起来我的更改已保存)?和/或是否有更好的方法来编写此代码以使其正常工作?

基本上表 1 中的信息也在表 2 中。我想要表 2 中的所有信息,除了表 1 中匹配的信息。

提前非常感谢你!!!

SELECT        TOP (100) PERCENT dbo.vwCOVIDLocations2.Hospital, dbo.vwCOVIDLocations2.Department, dbo.vwCOVIDLocations2.MRN, dbo.vwCOVIDLocations2.[Patient Name], dbo.vwCOVIDLocations2.[Order Date], 
                         dbo.vwCOVIDLocations2.Result
FROM            dbo.vwCOVIDDetected2 LEFT OUTER JOIN
                         dbo.vwCOVIDLocations2 ON dbo.vwCOVIDDetected2.MRN <> dbo.vwCOVIDLocations2.MRN AND dbo.vwCOVIDDetected2.[Order Date] <> dbo.vwCOVIDLocations2.[Order Date] AND 
                         dbo.vwCOVIDDetected2.Result <> dbo.vwCOVIDLocations2.Result
GROUP BY dbo.vwCOVIDLocations2.Hospital, dbo.vwCOVIDLocations2.Department, dbo.vwCOVIDLocations2.MRN, dbo.vwCOVIDLocations2.[Patient Name], dbo.vwCOVIDLocations2.[Order Date], dbo.vwCOVIDLocations2.Result
ORDER BY dbo.vwCOVIDLocations2.[Patient Name]
4

1 回答 1

1

我不确定它是否有帮助,但我不会增加超时。我会重写查询以加快执行速度,尤其是左外连接。您可以尝试以下方法:

SELECT TOP (100) PERCENT dbo.vwCOVIDLocations2.Hospital
    ,dbo.vwCOVIDLocations2.Department
    ,dbo.vwCOVIDLocations2.MRN
    ,dbo.vwCOVIDLocations2.[Patient Name]
    ,dbo.vwCOVIDLocations2.[Order Date]
    ,dbo.vwCOVIDLocations2.Result
FROM dbo.vwCOVIDLocations2
WHERE NOT EXISTS (
    SELECT 1 FROM dbo.vwCOVIDDetected2 
    WHERE
        dbo.vwCOVIDDetected2.MRN = dbo.vwCOVIDLocations2.MRN
        AND dbo.vwCOVIDDetected2.[Order Date] = dbo.vwCOVIDLocations2.[Order Date]
        AND dbo.vwCOVIDDetected2.Result = dbo.vwCOVIDLocations2.Result
    )
GROUP BY dbo.vwCOVIDLocations2.Hospital
    ,dbo.vwCOVIDLocations2.Department
    ,dbo.vwCOVIDLocations2.MRN
    ,dbo.vwCOVIDLocations2.[Patient Name]
    ,dbo.vwCOVIDLocations2.[Order Date]
    ,dbo.vwCOVIDLocations2.Result
ORDER BY dbo.vwCOVIDLocations2.[Patient Name]
于 2020-10-16T05:35:19.800 回答