SQL来自 SSMS 的 CMD 不工作;连接到 Azure SQL 数据库

SQLCMD from SSMS is not working; connecting to Azure SQL Database

运行 这是我的 SQL Server Management Studio (SSMS) 连接到 Azure sql 数据库。我正在使用 SSMS 的 SQLCMD 模式。

:Connect -S taiobdemo1.database.windows.net -d taiobcustomer -U sqlusername -P strongpw

出现此错误:

A fatal scripting error occurred. Incorrect syntax was encountered while parsing :Connect.

:connnect SqlCmd 命令不允许您指定目标数据库。您将始终连接到默认数据库。所以它在 Azure SQL 数据库中毫无用处,因为你将连接到 Master 并且无法切换。

例如

:Connect xxxx.database.windows.net  -U someuser -P xxxx
select db_name()

会一直输出master