SQL Hosting :: Store Results Of Query To File With sqlcmd

It is very easy to direct the output of the query to a new file with the help of sqlcmd. Here is the simple step to store results of query to file with sqlcmd :

1. Create SQL file which you want to execute. I have created SQL file testquery.sql and saved it in my drive.

2. Execute following sqlcmd command on prompt:

If you are using windows authentication execute following script

If you are using username and password run following script

3. Open the file generated by sqlcmd in the drive.

This is indeed a very simple process. If you have any question, you can go to asphostportal.com and ask question.