I have created a bcp query to write db data to a file.
bcp "SELECT ADObject,starttime,endtime FROM exam" queryout C:/ExamOut.csv -t, -c -S . -d exam