Export (0) Print
Expand All

Readme_SmoCompare

SQL Server 2005

Updated: 17 July 2006

This sample demonstrates techniques for implementing a comparison of two database objects. By using SQL Server Management Objects (SMO), the application lets the user compare property and schema information for two objects. The application demonstrates the general object properties, iteration through properties, and exception handling for errors relating to object properties.

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.

This sample requires that the following components are installed.

  • .NET Framework SDK 2.0 or Microsoft Visual Studio 2005. You can obtain .NET Framework SDK free of charge. See Installing the .NET Framework SDK.
  • Microsoft SQL Server 2005 Integration Services.
  • The sample package and data files that it uses must be installed on the local hard disk drive.
  • The AdventureWorks OLTP database must be installed.
  • The AdventureWorks database must be attached.
  • You must have administrative permissions on the AdventureWorks database.
  • You must compile the ServerConnect component first, because this sample has a dependency on the ServerConnect sample.

For more information about how to install samples, see "Installing Sample Integration Services Packages" in SQL Server Books Online.

If the code sample was installed to the default location, the sample is located in the following directory:

C:\Program Files\Microsoft SQL Server\90\Samples\Engine\Programmability\SMO\SmoCompare

The C# solution for the code sample is located in the CS directory, and the Visual Basic solution is located in the VB directory.

If you have not already created a strong name key file, generate the key file using the following instructions.

  1. Open a Microsoft Visual Studio 2005 command prompt. Click Start, point to All Programs, point to Microsoft .NET Framework SDK 2.0, and then click SDK Command Prompt.

    -- or --

    Open a Microsoft .NET Framework command prompt. Click Start, point to All Programs, point to Microsoft .NET Framework SDK 2.0, and then click SDK Command Prompt.

  2. Use the change directory command (CD) to change the current directory of the command prompt window to the folder where the samples are installed.
    ms161553.note(en-US,SQL.90).gifNote:
    To determine the folder where samples are located, click the Start button, point to All Programs, point to Microsoft SQL Server, point to Documentation and Tutorials, and then click Samples Directory. If the default installation location was used, the samples are located in <system_drive>:\Program Files\Microsoft SQL Server\100\Samples.
  3. At the command prompt, run the following command to generate the key file:

    sn -k SampleKey.snk

    ms161553.note(en-US,SQL.90).gifImportant:
    For more information about the strong-name key pair, see "Security Briefs: Strong Names and Security in the .NET Framework" in the .NET Development Center on MSDN.

  1. Open a .NET Framework or Microsoft Visual Studio 2005 command prompt. Use the change directory (CD) command to change the current directory of the command prompt window to the solution directory that you want to work in.

  2. Type the following command to build either the C# or the Visual Basic version of the sample:

    for /r %f in (*.sln) do msbuild.exe "%f"

  1. From the File menu in Microsoft Visual Studio 2005, click Open, click Project, and then open SmoCompare.sln in the solution directory that you want to work in.

  2. Press F5, or click Start on the Debug menu to compile and run the project.

The following types of database objects have been tested with this sample. Comparing other kinds of database objects is not supported.

  • Database
  • Table
  • Stored Procedure
  • View
  • User
  • Schemas
  • UserDefinedFunction
  • Role
  • Endpoint
  • JobServer

Release History

17 July 2006

Changed content:
  • Added comments section and information about which kinds of database objects are supported.

5 December 2005

Changed content:
  • Changed instructions for generating a key file, including the name and location of the key file.

Community Additions

ADD
Show:
© 2014 Microsoft