SMO Samples

[This topic is pre-release documentation and is subject to change in future releases. Blank topics are included as placeholders.]

This sample works only with SQL Server 2005 and SQL Server 2008. It will not work with any version of SQL Server earlier than SQL Server 2005.

The following table lists the SQL Server Management Objects (SMO) programming samples.

Samples are provided for educational purposes only. They are not intended to be used in a production environment and have not been tested in a production environment. Microsoft does not provide technical support for these samples. Sample applications and assemblies should not be connected to or used with your production SQL Server database or your report server without the permission of the system administrator.

Name Description

Readme_BackRest Sample

Demonstrates how to back up and restore a database.

ReadMe_CheckIdentityValues Sample

Performs identity checks on each table in the selected database.

Readme_CreateSPs Sample

Demonstrates how to create a SELECT stored procedure for each table in the selected database.

ReadMe_DatabaseDefrag Sample

Demonstrates techniques for implementing database defragmentation capabilities in database applications.

ReadMe_DatabaseSpace Sample

Demonstrates techniques for implementing database space monitoring applications.

Readme_DependencyExplorer Sample

Implements dependency tree and property display window.

ReadMe_IndexSizes Sample

Demonstrates techniques for implementing database index space monitoring applications.

Readme_LoadRegAssembly Sample

Demonstrates how to load and register a Microsoft .NET Assembly into Microsoft SQL Server. Uses the UtilityConversion assembly.

Readme_ManageDatabases Sample

Demonstrates how to create, alter, and drop a database. Includes adding a new file group and log file.

Readme_ManageDatabaseUsers Sample

Demonstrates how to add, modify, and remove users.

Readme_ManageTables Sample

Demonstrates how to create, alter, and drop tables.

ReadMe_RebuildAllIndexes Sample

Rebuilds all the indexes in the selected database.

Readme_ScriptTable Sample

Demonstrates how to script the dropping or creating of a table.

Readme_ServiceBrokerConfiguration Sample

Demonstrates how to create Service Broker objects by using SMO.

Readme_ServerConnect Sample

Demonstrates how to connect to the SQL Server system.

Readme_ServerInfo Sample

Displays a list of server and connection properties for the selected instance of SQL Server.

Readme_SmoBrowser Sample

Browses the hierarchy of SMO objects using .NET reflection.

Readme_SmoCompare Sample

Demonstrates techniques for implementing a comparison of two database objects.

ReadMe_SmoEvents Sample

Demonstrates techniques for displaying SQL Server events in a console database application.

Readme_SmoPing Sample

A console application that connects to the selected instance of SQL Server and dumps selected properties. Can be used to verify the SQL Server connection.

Readme_SmoScripter Sample

Demonstrates scripting and retrieving database object dependencies.

Readme_SqlServerList Sample

Enumerates a list of available instances of SQL Server.

Readme_SqlService Sample

Displays the SQL Server services that are available to start, stop, pause, and resume.

Readme_Tracer Sample

Reads and displays trace information from an instance of SQL Server.

Readme_UtilityConversion Sample

Used with LoadRegAssembly. Contains demonstration common language runtime functions for use with SQL Server.

Readme_VerifyBackup Sample

Verifies a backup on a backup device to ensure the data can be used to restore the database.

See Also

Other Resources

Preparing to Use SMO
Creating SMO Programs

Help and Information

Getting SQL Server 2008 R2 Assistance