0

I already got the csv file with data but i need data with columns I have many table which i need to execute at one go and save data in csv format at one location with header i don't want to add columns name as their 100 table. I am using below query

Declare @cmd varchar(8000)
Set @cmd='Bcp"select * from tablename where condition queryout "path" -s -T -f -t, -c -E
EXECUTE master..xp_cmdshell

Their 100 tables like that.. any suggestion

amitesh
  • 766
  • 5
  • 17
  • 39
  • you can't without a cludge such as this: http://stackoverflow.com/questions/1355876/export-table-to-file-with-column-headers-column-names-using-the-bcp-utility-an. BCP doesn't support exporting headers. Why do you need the headers? If it's for machine-to-machine transfer then the headers are irrelevant. If it's for presentation to the user then maybe bcp is not your best option - try out sqlcmd instead, or an SSIS package. – ADyson Feb 09 '17 at 11:42
  • you are correct ADyson i did it with stored procedure.. – amitesh Feb 10 '17 at 08:12

0 Answers0