Is there a way to suppress the "x lines affected" in SQLCMD from the command line?

Is there a way to suppress the "x lines affected" in SQLCMD from the command line?

I am running an MSBuild script and do not want it to clog my log on my build server.

I would prefer not to add β€œSET NOCOUNT ON” to every script, so if there is a way to do this from the command line, it will be fantastic.

+61
sql-server rows sqlcmd
Jan 6
source share
3 answers

How about creating a script run using SET NOCOUNT ON in the script (assign the script to the SQLCMDINI environment variable). http://msdn.microsoft.com/en-us/library/ms162773.aspx

+72
Jan 06 '10 at 16:08
source share

The -i and -q options are mutually exclusive .

Create a file called setnocount.sql with the contents:

 SET NOCOUNT ON; 

And you can do -i setnocount.sql,otherscript.sql using the multiple file function and effectively "including" the common first file.

+41
Jan 06 '10 at 21:17
source share

You can also run multiple lines in the -Q option, separated by a semicolon, as shown below

eg:

 -Q "set nocount on;select * from table;delete from table where some_condition=true" 
+27
Jan 15
source share



All Articles