What I need to do:
- I want to export data from SQL Server 2008 to a
CSV
in specific format. - I can't use the
BCP
utility for this. - I have exported
CSV
File usingSQLCMD
but the only issue is I need "Enter" as column or field separator in CSV file. - Then I saved
SQLCMD
file 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!