Using SQLCMD command we can execute the sql file and we can store the execution result in the file.
Below is the file.
This will return the result set. We will store this result set into the other files.
Opening the command prompt and writing the below command.
SQLCMD -E -S BAGESH\BAGESHDB -d AdventureWorksDW2017 -i J:\code\DimProduct.sql -o J:\code\DimProduct_resultset.txt |
CMD prompt
After run.
See the result.
Get the expected result.