sqlcmd rows affected

I was using sqlcmd to export some tables to text files.  The problem was at the bottom of every file there was a blank line and something like (83 rows affected).

I was going to just live with this.  But then had an aha moment.   I should have been using the BCP utility, not sqlcmd.

Here is how to export a table in BCP with the pipe delimiter, with a trusted connection:

bcp DBName.dbo.TableName out D:\FileName.txt -T -c -t”|”

Advertisements
This entry was posted in Database Administration and tagged . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s