Wayne Sheffield continues his SSMS tips & tricks series. He first covers SQLCMD:
Notice that all of the SQLCMD commands start with a colon (:)
The complete reference for how all of these commands work is at http://msdn.microsoft.com/en-us/library/ms162773.aspx. I will cover just a few of them in this blog post.
SETVAR allows you to set a variable for use throughout the script. Its syntax is SETVAR . For instance, “:SETVAR SourceServer .\SQL2005” will set the variable SourceServer to “.\SQL2005”, which is the name of the SQL 2005 instance on my laptop.
Then he talks about multi-server queries, including local server groups and using a Central Management Server. Having a CMS is critical when you have more than a couple of instances, and frankly, even then it can be helpful when bringing new people up to speed.
Wayne also covers the basics of regular expressions in SSMS.
All three of these are powerful tips.