Output Flat File using BCP (without output messages )

To extract CSV file from SQL server, BCP commands canbe used but they will output a line for every 1k rows. This might cause a delay in generating file for a million record table.

At the same time it can be handled using xp_cmdshell but no every envoronment would like to enable for security reasons.

So redirecting to NUL helps in our case.

bcp “select * from [calendar].[Auxiliary].[Calendar]” queryout “C:\temp\cal.csv” -T -t”,” -c 1>NUL

1
bcp "select * from [calendar].[Auxiliary].[Calendar]" queryout "C:\temp\sales.csv" -T -t"," -c 1>NUL

BCP_output

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>