Chapter 27. Automating SQL Server Management using SMO

 

Allen White

When managing Microsoft SQL Server, there is rarely just one best way to accomplish any given task. Server Management Objects (SMO) and its sisters, Replication Management Objects (RMO) and Analysis Management Objects (AMO), are object libraries that enable you to manage SQL Server to best fit your needs.

Microsoft provides excellent tools to manage SQL Server, but they may not always fit the skill set of your administrative team. For example, your operations team may be more inclined to script all management tasks (not a bad idea and the graphical tools provided don’t necessarily lend themselves to automation). SMO, introduced with SQL Server 2005, was built using the .NET Framework, so the objects it exposes are available in your language of choice. In this chapter, I’ll give examples using Visual Basic .NET, but you can build your own application using any .NET language.

Loading required libraries

Backup

Restore

Creating a database

Scripting

Summary

About the author