SSMS 执行视图超时
SSMS executing view timeout
我遇到了 SQL 执行错误的问题。我正在尝试执行视图,但收到“执行超时已过期”错误。下面是我 运行ning 的代码。我需要将此 运行 作为视图,因为这些 table 链接到自动更新的 dbo,并且我需要此视图与 MS Access 报告使用它时的视图一样最新。 (根据我的理解,视图不需要手动执行即可成为最新的)
我已尝试更改所有超时位置,包括“工具”->“选项”、“登录连接选项”和“注册表编辑器”,但我仍然遇到错误。
它在 30 秒后超时,那么我还能在哪里更改它?这是否不起作用,因为我没有完整的“IT 管理员”权限(即使看起来我的更改已保存)? And/Or 是否有更好的方法来编写此代码以使其有效?
基本上 table 1 中的信息也在 table 2 中。我想要 table 2 中的所有信息,除了 table 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]
我遇到了 SQL 执行错误的问题。我正在尝试执行视图,但收到“执行超时已过期”错误。下面是我 运行ning 的代码。我需要将此 运行 作为视图,因为这些 table 链接到自动更新的 dbo,并且我需要此视图与 MS Access 报告使用它时的视图一样最新。 (根据我的理解,视图不需要手动执行即可成为最新的)
我已尝试更改所有超时位置,包括“工具”->“选项”、“登录连接选项”和“注册表编辑器”,但我仍然遇到错误。
它在 30 秒后超时,那么我还能在哪里更改它?这是否不起作用,因为我没有完整的“IT 管理员”权限(即使看起来我的更改已保存)? And/Or 是否有更好的方法来编写此代码以使其有效?
基本上 table 1 中的信息也在 table 2 中。我想要 table 2 中的所有信息,除了 table 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]