how to import query execution message in a text file
Hi, I want to store my query execution message on somewhere on my drive. let say I execute a query select * from table_name; then it gives a msg '(30556 row(s) affected)' and I want to store this message in a text file. Is there any query or setting so I can do it along with my script?
If you run the T-SQL command from sqlcmd.exe or PowerShell, then you get the entire output that can be saved as a file. You can do the same thing if you're building your own commands using a programming language. If you're running the commands through Management Studio, you can have the output go to text instead of to grid. That will include messages with the results so that everything can be saved to a single file. In a query window you can right click on the query and select "Results to" from the context menu and then "Results to Text" or hit CTL-T in the query window. There's also a button on the toolbar.