SQLCMD provides a large number of scripting options that allow for a great amount of flexibility for dynamically running scripts. For instance, scripting variables can be embedded in scripts, which can be used as substitution parameters at runtime, thereby allowing generic database scripts to be written for large installations.
There is not enough space here to properly cover this tool; please consult SQL Server 2005 Books Online for a complete rundown.
Do you have comments on this Ask the Expert Q&A?
This was first published in December 2005