this is my data
select productid,productname from product
If this is Microsoft SQL Server, you can use "sqlcmd" command line tool.
See example here
How to export data as CSV format from SQL Server using sqlcmd?