Working with SMO in Microsoft Visual Studio

To get started working with SMO, you must first set a reference in the Visual Studio project to the SMO assembly by choosing Project, Add Reference and then selecting the Microsoft.SqlServer.Smo, Microsoft.SqlServer.SmoExtended, Microsoft.SqlServer.Management.Sdk.Sfc, and Microsoft.SqlServer.ConnectionInfo components, as shown in Figure 4-1.

Setting a reference to SMO

Figure 4-1. Setting a reference to SMO

You then add two using statements for the two namespaces that you will use most often, as shown here:

using Microsoft.SqlServer.Management.Common;
using Microsoft.SqlServer.Management.Smo;

Next you will want to work with SMO objects, ...

Get Programming Microsoft® SQL Server™ 2008 now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.