Link to Programming Samples


The following table lists the SQL Server Management Objects (SMO) programming samples that are available in the C:\Program Files\Microsoft SQL Server\120\Samples\Engine\Programmability\SMO directory. These samples are available in both Visual C# and Visual Basic .NET.

For more information about how to install samples, see AdventureWorks for SQL Server 2012.

BackRestDemonstrates how to back up and restore a database.
ChangeTableOwnerDemonstrates how to change ownership of all tables that are not dbo to dbo.
CreateSPsDemonstrates how to create a SELECT stored procedure for each table in the selected database.
DatabaseSearchDisplays all the objects in a database.
DependencyExplorerImplements dependency tree and property display window.
IndexSizesDisplays index name and size for the selected database.
LoadRegAssemblyDemonstrates how to load and register a Microsoft .NET Assembly into Microsoft SQL Server. Uses the UtilityConversion assembly.
ManageDatabasesDemonstrates how to create, alter, and drop a database. Includes adding a new file group and log file.
ManageDatabaseUsersDemonstrates how to add, modify, and remove users.
ManageTablesDemonstrates how to create, alter, and drop tables.
ScriptJobsDemonstrates how to script the dropping and creating of SQL Server Agent jobs.
ScriptTableDemonstrates how to script the dropping or creating of a table.
ServerConnectDemonstrates how to connect to the SQL Server system.
ServerInfoDisplays a list of server and connection properties for the selected instance of SQL Server.
SMOPingA console application that connects to the selected instance of SQL Server and dumps selected properties. Can be used to check the SQL Server connection.
SQLServerListEnumerates a list of available instances of SQL Server.
SQLServiceDisplays the SQL Server services that are available to start, stop, pause, and resume.
TracerReads and displays trace information from an instance of SQL Server.
TriggersDisplays database triggers.
UtilityConversionUsed with LoadRegAssembly. Contains demonstration common language runtime (CLR) functions for use with SQL Server.
VerifyBackupVerifies a backup on a backup device to ensure the data can be used to restore the database.

Community Additions