我遇到一个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]
我不确定这是否有帮助,但我不会增加超时时间。为了更快地执行,我会重写查询,尤其是左外部联接。您可以尝试以下操作:
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]