All the searches and posts I've come across use the following to export data to a CSV file, how ever I can't get it to work.
Here's a wrinkle, the file doesn't exist, the export has to create it.
How do I get BCP export to create the file and write data ???
I've created a #temp table with the records and now I need to use a select statement to get a single record from the #temp and create and write the file. How do i do this??
This is being done from within a proc.
Create Table #Temp
(
[ ..]
fields..
)
Declare @CSVexport varchar(8000)
set @CSVexport = 'BCP select
[Fld 1]
,[Fld 2]
,[Fld 3]
,[Fld 4]
,[Fld 5]
,[Fld 6]
From #temp where [Fld 7] = @ClientDocNo out C:\Test -c -T -S SERVER'
Exec master..xp_cmdshell @CSVexport
Our community of experts have been thoroughly vetted for their expertise and industry experience.