在 csv 中添加 Headers 名称
Add Headers name in the csv
目标:
我想将列的一些名称 header 从存储过程添加到 CSV 文件
bcp "EXEC [databasname].[storedprocedure]" queryout
C:\test\bcp_outputTable.csv -c -T -SPC01 -r\n
问题:
我找不到解决办法。
信息:
我在 CMD 中使用上面的代码。
rename "C:\test\bcp_outputTable.csv" "C:\test\bcp_outputTable.txt"
echo HeadRow1,HeadRow2,HeadRow3,... >"C:\test\bcp_outputTable.csv"
type "C:\test\bcp_outputTable.txt>>"C:\test\bcp_outputTable.csv"
del "C:\test\bcp_outputTable.txt"
@ECHO off
SET "location=c:\test\" SET filename=%date:~0,10%
ECHO This bat creates a csv file to the to the folder %location% ECHO
If you are ready, press the button space
PAUSE
BCP "[databasname].[storedprocedure]" queryout
%location%%filename%.txt -c -T -t; -SPC01 -r\n
:: Adding header in the csv file ECHO f;f;f>
%location%%filename%.csv
TYPE %location%%filename%.txt >> %location%%filename%.csv
DEL /s %location%%filename%.txt
PAUSE
目标:
我想将列的一些名称 header 从存储过程添加到 CSV 文件
bcp "EXEC [databasname].[storedprocedure]" queryout C:\test\bcp_outputTable.csv -c -T -SPC01 -r\n
问题:
我找不到解决办法。
信息:
我在 CMD 中使用上面的代码。
rename "C:\test\bcp_outputTable.csv" "C:\test\bcp_outputTable.txt"
echo HeadRow1,HeadRow2,HeadRow3,... >"C:\test\bcp_outputTable.csv"
type "C:\test\bcp_outputTable.txt>>"C:\test\bcp_outputTable.csv"
del "C:\test\bcp_outputTable.txt"
@ECHO off
SET "location=c:\test\" SET filename=%date:~0,10%
ECHO This bat creates a csv file to the to the folder %location% ECHO If you are ready, press the button space
PAUSE
BCP "[databasname].[storedprocedure]" queryout %location%%filename%.txt -c -T -t; -SPC01 -r\n
:: Adding header in the csv file ECHO f;f;f> %location%%filename%.csv
TYPE %location%%filename%.txt >> %location%%filename%.csv
DEL /s %location%%filename%.txt
PAUSE