问题
I'm writing a fairly long running script, which prints progress messages as it goes.
However, SQL Server Management Studio by default shows the resultset tab, not the messages tab, so the user will have to click the messages tab after starting the script to see the progress as it happens.
Is there a way for my script to tell SSMS to show the messages tab automatically?
I know SSMS will remove the resultset tab once the script is complete, since it doesn't generate any resultsets, but I want the messages tab shown immediately, not at the end.
I'm not looking for a setting within SSMS, since this script will not be run on my machine once released.
回答1:
There is not anything that you can include in your script to change the default behavior of the SSMS IDE, you might be able to handle it with a setting, but you noted that isn't a valid solution.
回答2:
you should forget about trying to do this in SSMS and use the sqlcmd
utility
Tutorial: sqlcmd Utility
Using SQL Server 2005 sqlcmd Utility
来源:https://stackoverflow.com/questions/3813788/can-i-get-ssms-to-switch-to-the-messages-tab-programatically