Use SET NOCOUNT ON in the SQL to suppress the rowcount.
To suppress the header, use the option -h-1
, for instance:
sqlcmd -h-1 -Q"SET NOCOUNT ON SELECT @@version"
This browser is no longer supported.
Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Hello
i need some help with sqlcmd utility at linux I have this select statement, but it display both at start with the -----
1> select 'grant select on ' + name + ' to READONLY' + CHAR(10) + 'go' from sysobjects where type = 'U' or type = 'V' or type = 'P'
2> go
------------------------------------------------------------------------------------------------------------------------------------
then a the end show the numbers
(34 rows affected)
how can the --- and the ( x rows affected) be ignored?
is there away in the sqlcmd to pass some parameter to ignore the lines?
thank you
Use SET NOCOUNT ON in the SQL to suppress the rowcount.
To suppress the header, use the option -h-1
, for instance:
sqlcmd -h-1 -Q"SET NOCOUNT ON SELECT @@version"
Hi @helena Matos ,
As Erland mentioned, to remove dashed line header, you can use -h
parameter with value -1
, and to remove row count, you should use “SET NOCOUNT ON” in query.
For example:
sqlcmd -S wx-80490 -h -1
1> set nocount on; select 'grant select on ' + name + ' to READONLY' + CHAR(10) + 'go' from sysobjects where type = 'U' or type = 'V' or type = 'P'
2>go
And
sqlcmd -S . -h -1 -Q "set nocount on; select 'grant select on ' + name + ' to READONLY' + CHAR(10) + 'go' from sysobjects where type = 'U' or type = 'V' or type = 'P'"
Please refer to the sqlcmd syntax for more details.
Best Regards,
Amelia
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.