What I need to do:
- I want to export data from SQL Server 2008 to a
CSVin specific format. - I can't use the
BCPutility for this. - I have exported
CSVFile usingSQLCMDbut the only issue is I need "Enter" as column or field separator in CSV file. - Then I saved
SQLCMDfile as windows batch file and executed that using CMD
For Example, (Note: test.sql contains a PLSql Block which return columns data.):
- I have saved below statement as batch file with name test.bat:
sqlcmd -S %1 -U %2 -P %3 -v DatabaseName = %4 -i %current_dir%\test.sql -o %current_dir%\test.csv -y0 -I -s "
"
- Then executed above in CMD using below command:
test.bat localhost user pass db_name
- But it gives output like:
""REC"""LINE"
- I want output like:
"Rec"
"LINE"
Any input is appreciated!
I used this syntax in my table and when i opened the file it gived to me some kind of the result you are asking for. Just try it if it is what you are requiring.