Exporting Large amounts of Data from SQL

If you have ever had an issue transfering large amount of data from SQL you can use the command line tool to solve this problem.

From the command line

bcp [<database_name.>[<owner>].]<table_name> out <csv-file> [/U<username>] [/P<password>] [/S<server_name>] /c /t

<database_name> is an optional parameter specifying the name of the database. It can only be omitted if the desired database is the default database.
<owner> the name of the table owner.
<table_name> the name of the table.
<csv-file> The name of the comma separated file to generate.
<username> The SQL Server username to use. This can be left blank if NT authentication is used.
<password> The password to use for the account.
<server_name> The name of the server on which the database resides. This can be omitted if the database is on the local machine (i.e. the same machine. as the bcp command is issued from).

For example

bcp myDatabase.dbo.MyTable out Output.csv

This is less bulking and a lot faster than using the built in function within Enterprise Manager.

Author Danny Mehmed

Add Comment

Name
Comment
 

Your comment has been received and will be shown once it passes moderation.