Friday, November 8, 2019

How to execute SQL query on CMD using text file and log result in text file

SQLcmd is small and easy to use tool is us with from last few decades. For starters SQL CMD is good and for some developers they are use to on cmd screen. They love to do query upon the screen, all is about the taste of doing work.

SQLCMD is command line can be used with in the cmd itself. You can execute the sql some Tsqls and any type of query using script. So this article is about the same that how to execute sql from script file using a sqlcmd.

At the same time we can generate the output of the script which is being executed in sqlcmd using "-o" parameter.

SQL script can be call using "-i" parameter.

sqlcmd -S IP_ADDRESS -d Database_Name -U Username -P Password -i C:\Users\***\Desktop\test.sql -o C:\Users\***\Desktop\test1.log

No comments:

Post a Comment

web stats