Sqlcmd: The -h and the -y 0 options are mutually exclusive?
We have an old batch-file (.bat-file) that includes the following sqlcmd code:
sqlcmd -S SERVER_NAME -d DB_NAME -I -Q "SELECT COUNT(*) FROM TableName WHERE ColumnName = 'SpecificValue'" -h-1 -k2 -y0
This code has been running on a Windows Server 2012 for years without any problems. Now we are migrating to a new server with Windows Server 2016 and the above sqlcmd-code no longer works and returns the message:
"Sqlcmd: The -h and the -y 0 options are mutually exclusive."
A couple of questions:
- Why does this scenario occur on the Windows Server 2016 server and
not on the Windows Server 2012 server? I’m not able to find any
documenation or information that the -h and the –y0 options are
mutually exclusive? - If the -h and the -y 0 options now are mutually exclusive, does
this mean that–y0 officially will suppress a header the same way
that –h does? I.e. can we remove the ”-h-1” part of the code and
expect the same results with only ”-y0”?
SQL Server versions the different servers:
SQL Server Version on the Windows Server 2012: 11.0.7462.6
SQL Server Version on the Windows Server 2016: 13.0.52.16.0
sql-server batch-file sqlcmd
add a comment |
We have an old batch-file (.bat-file) that includes the following sqlcmd code:
sqlcmd -S SERVER_NAME -d DB_NAME -I -Q "SELECT COUNT(*) FROM TableName WHERE ColumnName = 'SpecificValue'" -h-1 -k2 -y0
This code has been running on a Windows Server 2012 for years without any problems. Now we are migrating to a new server with Windows Server 2016 and the above sqlcmd-code no longer works and returns the message:
"Sqlcmd: The -h and the -y 0 options are mutually exclusive."
A couple of questions:
- Why does this scenario occur on the Windows Server 2016 server and
not on the Windows Server 2012 server? I’m not able to find any
documenation or information that the -h and the –y0 options are
mutually exclusive? - If the -h and the -y 0 options now are mutually exclusive, does
this mean that–y0 officially will suppress a header the same way
that –h does? I.e. can we remove the ”-h-1” part of the code and
expect the same results with only ”-y0”?
SQL Server versions the different servers:
SQL Server Version on the Windows Server 2012: 11.0.7462.6
SQL Server Version on the Windows Server 2016: 13.0.52.16.0
sql-server batch-file sqlcmd
1
The difference will very likely be the version ofsqlcmd
you are using, not the version of SQL Server. You can find out the version ofsqlcmd
you are using my using the-?
switch; the second output line gives you the version (for example, I haveVersion 14.0.3026.27 NT
). In regards to your second bullet point, have you tried? That would be the easiest way to find out.
– Larnu
Nov 23 '18 at 10:31
add a comment |
We have an old batch-file (.bat-file) that includes the following sqlcmd code:
sqlcmd -S SERVER_NAME -d DB_NAME -I -Q "SELECT COUNT(*) FROM TableName WHERE ColumnName = 'SpecificValue'" -h-1 -k2 -y0
This code has been running on a Windows Server 2012 for years without any problems. Now we are migrating to a new server with Windows Server 2016 and the above sqlcmd-code no longer works and returns the message:
"Sqlcmd: The -h and the -y 0 options are mutually exclusive."
A couple of questions:
- Why does this scenario occur on the Windows Server 2016 server and
not on the Windows Server 2012 server? I’m not able to find any
documenation or information that the -h and the –y0 options are
mutually exclusive? - If the -h and the -y 0 options now are mutually exclusive, does
this mean that–y0 officially will suppress a header the same way
that –h does? I.e. can we remove the ”-h-1” part of the code and
expect the same results with only ”-y0”?
SQL Server versions the different servers:
SQL Server Version on the Windows Server 2012: 11.0.7462.6
SQL Server Version on the Windows Server 2016: 13.0.52.16.0
sql-server batch-file sqlcmd
We have an old batch-file (.bat-file) that includes the following sqlcmd code:
sqlcmd -S SERVER_NAME -d DB_NAME -I -Q "SELECT COUNT(*) FROM TableName WHERE ColumnName = 'SpecificValue'" -h-1 -k2 -y0
This code has been running on a Windows Server 2012 for years without any problems. Now we are migrating to a new server with Windows Server 2016 and the above sqlcmd-code no longer works and returns the message:
"Sqlcmd: The -h and the -y 0 options are mutually exclusive."
A couple of questions:
- Why does this scenario occur on the Windows Server 2016 server and
not on the Windows Server 2012 server? I’m not able to find any
documenation or information that the -h and the –y0 options are
mutually exclusive? - If the -h and the -y 0 options now are mutually exclusive, does
this mean that–y0 officially will suppress a header the same way
that –h does? I.e. can we remove the ”-h-1” part of the code and
expect the same results with only ”-y0”?
SQL Server versions the different servers:
SQL Server Version on the Windows Server 2012: 11.0.7462.6
SQL Server Version on the Windows Server 2016: 13.0.52.16.0
sql-server batch-file sqlcmd
sql-server batch-file sqlcmd
edited Nov 23 '18 at 15:15
Squashman
8,66931933
8,66931933
asked Nov 23 '18 at 10:26
DannyDanny
82
82
1
The difference will very likely be the version ofsqlcmd
you are using, not the version of SQL Server. You can find out the version ofsqlcmd
you are using my using the-?
switch; the second output line gives you the version (for example, I haveVersion 14.0.3026.27 NT
). In regards to your second bullet point, have you tried? That would be the easiest way to find out.
– Larnu
Nov 23 '18 at 10:31
add a comment |
1
The difference will very likely be the version ofsqlcmd
you are using, not the version of SQL Server. You can find out the version ofsqlcmd
you are using my using the-?
switch; the second output line gives you the version (for example, I haveVersion 14.0.3026.27 NT
). In regards to your second bullet point, have you tried? That would be the easiest way to find out.
– Larnu
Nov 23 '18 at 10:31
1
1
The difference will very likely be the version of
sqlcmd
you are using, not the version of SQL Server. You can find out the version of sqlcmd
you are using my using the -?
switch; the second output line gives you the version (for example, I have Version 14.0.3026.27 NT
). In regards to your second bullet point, have you tried? That would be the easiest way to find out.– Larnu
Nov 23 '18 at 10:31
The difference will very likely be the version of
sqlcmd
you are using, not the version of SQL Server. You can find out the version of sqlcmd
you are using my using the -?
switch; the second output line gives you the version (for example, I have Version 14.0.3026.27 NT
). In regards to your second bullet point, have you tried? That would be the easiest way to find out.– Larnu
Nov 23 '18 at 10:31
add a comment |
1 Answer
1
active
oldest
votes
As I mentioned in my comment, the easiest way to find out if only using one of the switches gives the same output is to actually test. I tested this both on Windows (Version 14.0.3026.27 NT
) and Ubuntu (Version 17.2.0000.1 Linux
) for completion and got the following results:
Windows:
PS Z:> sqlcmd -S "srvsql2012devSandbox" -E -Q "SELECT 1 AS One;" -h-1 -y0
Sqlcmd: The -h and the -y 0 options are mutually exclusive.
PS Z:> sqlcmd -S "srvsql2012devSandbox" -E -Q "SELECT 1 AS One;" -h-1
1
(1 rows affected)
PS Z:> sqlcmd -S "srvsql2012devSandbox" -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)
Note that there is a slight difference in the indentation. I don't know what your output looked like before, but i suspect one of these replicates the output you had before.
Thanks @Larnu for your answer, I tested both options in accordance with your answer and both actually seems to work for us! The first one, i.e. to only use ”-h-1”, have the same indentation as our previous output. However, both options still seem to work for us as we in the next step in the code/script use the output value in an if-statement. I.e. the script works as expected and the indentation does not seem to have an affect on this specific scenario.
– Danny
Nov 23 '18 at 12:40
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444899%2fsqlcmd-the-h-and-the-y-0-options-are-mutually-exclusive%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
As I mentioned in my comment, the easiest way to find out if only using one of the switches gives the same output is to actually test. I tested this both on Windows (Version 14.0.3026.27 NT
) and Ubuntu (Version 17.2.0000.1 Linux
) for completion and got the following results:
Windows:
PS Z:> sqlcmd -S "srvsql2012devSandbox" -E -Q "SELECT 1 AS One;" -h-1 -y0
Sqlcmd: The -h and the -y 0 options are mutually exclusive.
PS Z:> sqlcmd -S "srvsql2012devSandbox" -E -Q "SELECT 1 AS One;" -h-1
1
(1 rows affected)
PS Z:> sqlcmd -S "srvsql2012devSandbox" -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)
Note that there is a slight difference in the indentation. I don't know what your output looked like before, but i suspect one of these replicates the output you had before.
Thanks @Larnu for your answer, I tested both options in accordance with your answer and both actually seems to work for us! The first one, i.e. to only use ”-h-1”, have the same indentation as our previous output. However, both options still seem to work for us as we in the next step in the code/script use the output value in an if-statement. I.e. the script works as expected and the indentation does not seem to have an affect on this specific scenario.
– Danny
Nov 23 '18 at 12:40
add a comment |
As I mentioned in my comment, the easiest way to find out if only using one of the switches gives the same output is to actually test. I tested this both on Windows (Version 14.0.3026.27 NT
) and Ubuntu (Version 17.2.0000.1 Linux
) for completion and got the following results:
Windows:
PS Z:> sqlcmd -S "srvsql2012devSandbox" -E -Q "SELECT 1 AS One;" -h-1 -y0
Sqlcmd: The -h and the -y 0 options are mutually exclusive.
PS Z:> sqlcmd -S "srvsql2012devSandbox" -E -Q "SELECT 1 AS One;" -h-1
1
(1 rows affected)
PS Z:> sqlcmd -S "srvsql2012devSandbox" -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)
Note that there is a slight difference in the indentation. I don't know what your output looked like before, but i suspect one of these replicates the output you had before.
Thanks @Larnu for your answer, I tested both options in accordance with your answer and both actually seems to work for us! The first one, i.e. to only use ”-h-1”, have the same indentation as our previous output. However, both options still seem to work for us as we in the next step in the code/script use the output value in an if-statement. I.e. the script works as expected and the indentation does not seem to have an affect on this specific scenario.
– Danny
Nov 23 '18 at 12:40
add a comment |
As I mentioned in my comment, the easiest way to find out if only using one of the switches gives the same output is to actually test. I tested this both on Windows (Version 14.0.3026.27 NT
) and Ubuntu (Version 17.2.0000.1 Linux
) for completion and got the following results:
Windows:
PS Z:> sqlcmd -S "srvsql2012devSandbox" -E -Q "SELECT 1 AS One;" -h-1 -y0
Sqlcmd: The -h and the -y 0 options are mutually exclusive.
PS Z:> sqlcmd -S "srvsql2012devSandbox" -E -Q "SELECT 1 AS One;" -h-1
1
(1 rows affected)
PS Z:> sqlcmd -S "srvsql2012devSandbox" -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)
Note that there is a slight difference in the indentation. I don't know what your output looked like before, but i suspect one of these replicates the output you had before.
As I mentioned in my comment, the easiest way to find out if only using one of the switches gives the same output is to actually test. I tested this both on Windows (Version 14.0.3026.27 NT
) and Ubuntu (Version 17.2.0000.1 Linux
) for completion and got the following results:
Windows:
PS Z:> sqlcmd -S "srvsql2012devSandbox" -E -Q "SELECT 1 AS One;" -h-1 -y0
Sqlcmd: The -h and the -y 0 options are mutually exclusive.
PS Z:> sqlcmd -S "srvsql2012devSandbox" -E -Q "SELECT 1 AS One;" -h-1
1
(1 rows affected)
PS Z:> sqlcmd -S "srvsql2012devSandbox" -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)
Note that there is a slight difference in the indentation. I don't know what your output looked like before, but i suspect one of these replicates the output you had before.
answered Nov 23 '18 at 10:47
LarnuLarnu
17.4k41731
17.4k41731
Thanks @Larnu for your answer, I tested both options in accordance with your answer and both actually seems to work for us! The first one, i.e. to only use ”-h-1”, have the same indentation as our previous output. However, both options still seem to work for us as we in the next step in the code/script use the output value in an if-statement. I.e. the script works as expected and the indentation does not seem to have an affect on this specific scenario.
– Danny
Nov 23 '18 at 12:40
add a comment |
Thanks @Larnu for your answer, I tested both options in accordance with your answer and both actually seems to work for us! The first one, i.e. to only use ”-h-1”, have the same indentation as our previous output. However, both options still seem to work for us as we in the next step in the code/script use the output value in an if-statement. I.e. the script works as expected and the indentation does not seem to have an affect on this specific scenario.
– Danny
Nov 23 '18 at 12:40
Thanks @Larnu for your answer, I tested both options in accordance with your answer and both actually seems to work for us! The first one, i.e. to only use ”-h-1”, have the same indentation as our previous output. However, both options still seem to work for us as we in the next step in the code/script use the output value in an if-statement. I.e. the script works as expected and the indentation does not seem to have an affect on this specific scenario.
– Danny
Nov 23 '18 at 12:40
Thanks @Larnu for your answer, I tested both options in accordance with your answer and both actually seems to work for us! The first one, i.e. to only use ”-h-1”, have the same indentation as our previous output. However, both options still seem to work for us as we in the next step in the code/script use the output value in an if-statement. I.e. the script works as expected and the indentation does not seem to have an affect on this specific scenario.
– Danny
Nov 23 '18 at 12:40
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53444899%2fsqlcmd-the-h-and-the-y-0-options-are-mutually-exclusive%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
The difference will very likely be the version of
sqlcmd
you are using, not the version of SQL Server. You can find out the version ofsqlcmd
you are using my using the-?
switch; the second output line gives you the version (for example, I haveVersion 14.0.3026.27 NT
). In regards to your second bullet point, have you tried? That would be the easiest way to find out.– Larnu
Nov 23 '18 at 10:31