gpt4 book ai didi

tsql - 在 Azure SQL Server 中使用分号时出错

转载 作者:行者123 更新时间:2023-12-01 03:17:31 24 4
gpt4 key购买 nike

我正在使用 Microsoft SQL Azure (RTM) - 12.0.2000.8 Nov 29 2017 09:37:51 Copyright (C) 2017 Microsoft Corporation与 compatibilty_level=120 以及当我运行此查询时

ALTER PROCEDURE SPCreateSession3
@a int,
@b int
AS
select count(*) as a from events where IDevent > @a;
select count(*) as b from sessions where IDsession > @b;
GO
exec SPCreateSession3 1, 1

它给了我错误 Must declare the scalar variable @b .没有分号,它工作正常。看起来是这样的 ;是 caugin 某种 GO命令。那为什么很多人建议 here ,那 ;永远不会造成任何问题。我需要分号,因为我在现实中使用了 MERGE 命令,其中 ;是必要的。另外,如果我将查询包装在 BEGIN 块中,例如
ALTER PROCEDURE SPCreateSession3
@a int,
@b int
AS
BEGIN
select count(*) as a from events where IDevent > @a;
select count(*) as b from sessions where IDsession > @b;
END
GO
exec SPCreateSession3 1, 1

然后,sql server 说 incorrect syntax near ; .由于分号再次出现问题。我是否遗漏了什么或分号真的应该归咎于此?当我需要使用分号而不出现这两个错误时,有什么解决方法?

快照: Error

最佳答案

作为此问题的解决方法,请使用 Microsoft SQL Operations Studio 作为 Linux 和 MAC 的替代查询编辑器。从 here 下载.使用 Operations Studio 不会有此问题。

用户目前要求使 SQL Server Management Studio 成为跨平台工具,如您所见 here .现在您可以使用 Microsoft SQL Operations Studio。

关于tsql - 在 Azure SQL Server 中使用分号时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47966339/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com