SQLCMD - how to Suppress output



  • 1. Simple SQL Server Administration from within a .NET Application
    I am trying to do really REALLY simple stuff like Starting and Stopping SQL Server from within a C# .NET application and, for the life of me, can't figure out the "proper" way to do it.... while I'm at it, restarting IIS would be nice too! Alex
  • 2. Truncated data using DTS
    I'm trying to import an .xls file into a table using DTS, but some of the records are being truncated. I have the datatype for the field in the table set to nvarchar 600, but only 255 characters are being imported. How can I import the data correctly? Thank you, Richard
  • 3. MSDE and Enterprise Manager Trouble
    I have installed an MSDE instance on my PC. I have used both the setup.exe program and installed MSDE with the merge modules. Everything works fine - I am able to programmatically connect to the database and execute all of my statements. However, when I try to register the database with Enterprise Manager, Enterprise Manager doesn't see the instance. Similarly, my program that uses SQLDMO.DLL to enumerate all servers does not see the MSDE instance. Both the database, my program, and Enterprise Manager are running locally on the same machine. This is a development box, and I have had to uninstall MSDE by hand several times by removing registry keys manually. I suspect that my problem is that I have deleted a key that I needed. Does anyone have any clues? Thanks in advance. Rob Reagan
  • 4. Good and small toolbox for MS-SQL?
    Hi: I'm looking for an app that does not require installation (single exe type of app) that I can use for querying, editing (via a grid) and exporting data from MSSQL, does anyone know of such a tool? The reason I don't want to install a multiple dll app is so I can carry the app around on CD to my clients and use it on their machines and take it away with me when I finish. TIA, Martin.
  • 5. Importing a text file
    I am trying to import a text file into an existing table using the DTS wizard. I am having trouble getting it to accept a couple of date fields. Is there a date format that the wizard will accept? If not, how should I import date fields? Thanks, -- Tim

SQLCMD - how to Suppress output

Postby sdragolov » Tue, 24 Oct 2006 02:59:33 GMT

Is it possible to suppress/turn-off the output that is returned from
queries within  a script when executing it with sqlcmd utility ?? I
don't want to write the output to a file, just want to turn it off.

Or is the only way to make it into a stored procedure?


Re: SQLCMD - how to Suppress output

Postby Erland Sommarskog » Tue, 24 Oct 2006 07:51:07 GMT

 ( XXXX@XXXXX.COM ) writes:

You could redirect output to NUL: to lose it entirely.

Or are there pieces in the output you do want to see?

Erland Sommarskog, SQL Server MVP,  XXXX@XXXXX.COM 

Books Online for SQL Server 2005 at
Books Online for SQL Server 2000 at

Similar Threads:

1.Suppressing messages using SQLCMD

I'm using SQLCMD to run a long list of relatively small scripts and
using the -o parameter to save the output (and check for errors).

The problem is that a couple of the scripts have cursors and "(1 row
affected)" is written every time.  This causes the scripts to taken an
excessive amount of time to run as there are hundreds of thousands of
rows and each one is written to the output file.

I could turn off the -o option for those scripts but then I'd lose all
error information.

Is there a way to do something like this:  suppress the "(1 row
affected)" messages and only record errors?

This is SQL 2005.

2.Get sqlcmd output into a table?

I'd like to get the output from the sqlcmd statement !!sqlcmd /Lc into a table.
The cmd runs fine in SSMS and returns the list of SQL Servers in the Results 
window.  I've tried a number of variations on this approach without success:

CREATE TABLE #tblSQLServers (ServerName [varchar](50))
!!sqlcmd /Lc
SELECT * FROM #tblSQLServers

Does anyone know of a way to do this?


3.sqlcmd output is UTF-8

If I create a simple sqlcmd script:

:out c:\temp\temp2.sql



and run it, the output appears to be UTF-8.  This causes problems not least 
because SSMS saves code as ANSI.  I can open the output files in Notepad and 
save them as ANSI, but obviously this is not practical for large numbers of 

UTF-8 isn't the problem so much as How can I override it?

Is there any way to override this setting when using sqlcmd mode from SSMS?


4.sqlcmd output and line break / carriage return


I am trying to catch someout put from sqlcmd in CSV format. Its kind
of going will apart from one of the columns is a free text column
(varchar ?) and has line break / carriage return and this is wrecking
the CSV output file .. or more correctly .. Excel is having issues
importing it.

My command is this ..

sqlcmd -S PC2\SQLEXPRESS -i invoiceExceptionsBatch.sql -o ID
Is there anything I can add to remove the line break / carriage
returns ?

Thanks in advance



5.SQLCMD Output


The documentation says that sqlcmd shows column headers above an output resultset.
That is what I want.

I use the -o parameter (tried the >> operator also) to put the output in a file.
There are no column headers in the file.
Am I missing something? Maybe a switch?

Thank You


6. sqlcmd outputs different

7. sqlcmd and Hebrew output

8. sqlcmd csv output



Who is online

Users browsing this forum: No registered users and 61 guest