Wednesday, 29 July 2015

SQL: BCP


Sample

In one batch file named "test.bat", perform the BCP to extract the records from the database through a stored procedure:

bcp "EXEC get_she_codes %1" queryout "%2.csv" -c -t, -S localhost -T

In another batch file, call test.bat to create the csv file: From here, you can call test.bat multiple times using different parameters:
call test.bat 1039646 JennyCompany-%date:~-4,4%%date:~-10,2%%date:~-7,2%
Output file:
JennyCompany-20153007.csv

No comments:

Post a Comment