如何运行:connect(本地)

如何运行:connect(本地)

当我在 SQL Server 2008 R2 上运行以下命令时,出现了Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ':'.什么错误?

:连接(本地)  

使用 msdb  

答案1

您需要在 SSMS 中启用 SQLCMD 模式。单击查询下拉菜单,然后选择“SQLCMD 模式”。然后您就可以运行查询了。

答案2

删除该行上的 local 和 GO 周围的括号。此外,GO 语句应单独成行(我发现您的源代码中有这种情况,这只是格式异常)。

:CONNECT local
USE msdb
GO

相关内容