I have an VB app that I am attempting to teach to export a SQL View to a CSV file.
I have gotten as far as:
But there are two problems:
1. I need to enclose char fields in double quotes (the data has commas).
2. I need to include field names as the first record.
This output file will be FTPed to users and creates a file over 10 Mb when exported to an Excel file. I am thinking the CSV format would be signifantly smaller.
My plan is to set up a Stored Proc to handle this file creation, then call the SP from VB.
Final question for now, is this the way to go?
TIA for any help.
I have gotten as far as:
Code:
Set NoCount ON
exec master.dbo.xp_cmdshell 'bcp "select * from imis.dbo.vDistrictDB3" queryout "F:\data\testout.csv" -c -T -t, -Usa -Ppwd'
But there are two problems:
1. I need to enclose char fields in double quotes (the data has commas).
2. I need to include field names as the first record.
This output file will be FTPed to users and creates a file over 10 Mb when exported to an Excel file. I am thinking the CSV format would be signifantly smaller.
My plan is to set up a Stored Proc to handle this file creation, then call the SP from VB.
Final question for now, is this the way to go?
TIA for any help.