Sqlcmd:-h 和-y 0 选项相互排斥?

Sqlcmd: The -h and the -y 0 options are mutually exclusive?

我们有一个旧的 batch-file (.bat-file),其中包含以下 sqlcmd 代码:

sqlcmd -S SERVER_NAME -d DB_NAME -I -Q "SELECT COUNT(*) FROM TableName WHERE ColumnName = 'SpecificValue'" -h-1 -k2 -y0

此代码已在 Windows Server 2012 上 运行 多年,没有任何问题。现在我们正在迁移到新服务器 Windows Server 2016 及以上 sqlcmd-code 不再有效并且 returns 消息:

"Sqlcmd: The -h and the -y 0 options are mutually exclusive."

几个问题:

SQL 不同服务器的服务器版本:

正如我在评论中提到的,要确定仅使用其中一个开关是否提供相同输出的最简单方法是实际测试。我在 Windows (Version 14.0.3026.27 NT) 和 Ubuntu (Version 17.2.0000.1 Linux) 上测试了这个是否完成并得到了以下结果:

Windows:

PS Z:\> sqlcmd -S "srvsql2012dev\Sandbox" -E -Q "SELECT 1 AS One;" -h-1 -y0
Sqlcmd: The -h and the -y 0 options are mutually exclusive.
PS Z:\> sqlcmd -S "srvsql2012dev\Sandbox" -E -Q "SELECT 1 AS One;" -h-1
          1

(1 rows affected)
PS Z:\> sqlcmd -S "srvsql2012dev\Sandbox" -E -Q "SELECT 1 AS One;" -y0
1

(1 rows affected)

Ubuntu:

larnu@qebui:~$ sqlcmd -S "localhost" -U larnu -Q "SELECT 1 AS One;" -h-1 -y0
Sqlcmd: The -h and the -y 0 options are mutually exclusive.
larnu@qebui:~$ sqlcmd -S "localhost" -U larnu -Q "SELECT 1 AS One;" -h-1
Password:
          1

(1 rows affected)
larnu@qebui:~$ sqlcmd -S "localhost" -U larnu -Q "SELECT 1 AS One;" -y0
Password:
1

(1 rows affected)

请注意,缩进略有不同。我不知道你之前的输出是什么样子,但我怀疑其中一个复制了你之前的输出。