BCP is one of the fastest methods to export data to various formats like csv,txt,etc and doing this in a command mode is faster than doing it via SSMS.
Let us create this simple table
create table test(id int, name varchar(50)) insert into test(id,name) select 1,'Sankar' union all select 2,'Kumar' union all select 3,'Nilesh'
Now open the command processor and run this code (Replace dbname,Servername, username and password with actual values)
BCP dbname..test out "C:\test.csv" -c -S Servername -U username -P Password
The data from the table test is now available in the file test.csv. When you open the file, you can notice that the column terminator is a tab. If you want to change it to a comma(,) or a pipe sysmbol (|), or any other character as terminatiors use the option -t followed by terminator. So the following code uses comma as the column terminator
BCP test..test out "C:\test.csv" -c -t, -S Servername -U username -P Password
If you want pipe symbol as a column terminator, use the following code
BCP test..test out "C:\test.csv" -c -t"|" -S Servername -U username -P Password
Note that only a comma can be specified without double quotes. All other terminators should be specified within double quotes.
So use the column terminator option -t to change the column terminator as you wish
Clik here to view.
