In Chapter 10, you learned about the most common maintenance tasks that you'll be called upon to perform as a database administrator. Many of those tasks are routine and also tedious. They are great candidates for automation, and one way to automate is through scripting.
You have two scripting environments at your disposal. One is
SQLCMD, a command-line utility that has been around since the introduction of SQL Server 2005. The other is PowerShell, a newer and more expressive scripting environment that addresses the needs of DBAs, system administrators, and even power users.
SQLCMD is a Win32 command prompt utility that allows the interactive execution of Transact-SQL statements ...