I am using the following query to export data into a file:
INSERT INTO OPENROWSET('Microsoft.ACE.OLEDB.12.0','Text;Database=C:\shared_files;HDR=YES;FMT=Delimited','SELECT * FROM [existing_file.csv]')
SELECT field_A, field_B, field_C FROM myTable
After executing, the result in the file (C:\shared_files\existing_file.csv) is:
myField_A,myField_B,myField_C
"1","customer 01","address 01"
"2","customer 02","address 02"
"3","customer 03","address 03"
I want to obtain it delimited by semicolon and without quotation marks, as the following example:
myField_A,myField_B,myField_C
1;customer 01;address 01
2;customer 02;address 02
3;customer 03;address 03
I've researched, but did not find the syntax for OPENROWSET options.
https://learn.microsoft.com/pt-br/sql/t-sql/functions/openrowset-transact-sql?view=sql-server-ver15
How to use OpenRowSet to insert data into a blank file?
INSERT INTO OPENROWSET Syntax with Dynamic T-SQL
If necessary, the file extension may be changed.
Does anyone knows how to set the options in the OPENROWSET above to get that desired result ?