这是一个简单的tsql文件:
# file foo.sql :
DROP TABLE IF EXISTS "Testing";
CREATE TABLE "Testing"
(
"Id" BIGINT NOT NULL,
"FilePath" NVARCHAR (442) NULL,
CONSTRAINT "PK_Testing" PRIMARY KEY CLUSTERED ("Id" ASC)
);
GO
当我通过SQL Server Management Studio加载它时,一切都很好:
输出:
Commands completed successfully.
Completion time: 2019-11-07T10:48:37.3336032+01:00
当通过sqlcmd
将其用作输入时,出现错误:
> sqlcmd -S .\SQLEXPRESS -d DemoDb -i foo.sql
Msg 102, Level 15, State 1, Server MY-LAPTOP\SQLEXPRESS, Line 1
Incorrect syntax near 'Testing'.
问题
在这种情况下,我如何告诉sqlcmd
表现得像SSMS?
我应该使用其他行为类似于SSMS的命令行工具吗?
版本信息:
> sqlcmd -?
Microsoft (R) SQL Server Command Line Tool
Version 15.0.1300.359 NT
Copyright (C) 2019 Microsoft Corporation. All rights reserved.
usage: ...
SSMS:v18.3.1
Component name Versions
SQL Server Management Studio 15.0.18183.0
Microsoft Analysis Services Client Tools 15.0.1487.0
Microsoft Data Access Components (MDAC) 10.0.18362.1
Microsoft MSXML 3.0 6.0
Microsoft Internet Explorer 9.11.18362.0
Microsoft .NET Framework 4.0.30319.42000
Operating System 10.0.18362