Be careful for following lines
replace <element> with your local environment elements
remove "<" ," >" signs
e.g. use master
1 use <database>
8 @dbName varchar(100) = '<database name>',
9 @sql varchar(8000) = 'select <col1,col2,col3....col4> from <table>',
10 @fullFileName varchar(100) = '<output file path>'
57 SET @bcpCommand = @bcpCommand + ' C:\Temp\test.csv -c -w -T -U sa -P sa","-CRAW'
58 EXEC <database>..xp_cmdshell @bcpCommand