Welcome to MSDN Blogs Sign in | Join | Help

Patrick Sirr's Blog

DataDude Notes
Data Compare DTE Commands

In this blog I’ll lead you through the various parameters for the “Data.NewDataComparison” command available in the General Distribution Release (GDR) for Visual Studio Team System 2008 Database Edition. This command launches the Visual Studio Data Compare editor.

If you have the Visual Studio Team System 2008 GDR installed, open it and navigate to the Command Window. To display the Command Window, open the View menu, point to Other Windows, and click Command Window. At the prompt type “Data.NewDataComparison”. The New Data Comparison dialog will appear. This is the expected result when executing “Data.NewDataComparison” without parameters. To avoid this dialog and immediately produce a data comparison result the following parameters are available:

Data.NewDataComparison /SrcServerName srcServer /SrcDatabaseName srcDatabaseName /SrcDisplayName displayName [/SrcUserName username] [/SrcPassword password] /TargetServerName targetServer /TargetDatabaseName targetDatabaseName /TargetDisplayName displayName [/TargetUserName username] [/TargetPassword password]

The command will have the general form is “Data.NewDataComparison <source options> <target options>”

/SrcServerName

/TargetServerName

This identifies the type of the source or target provider in the schema compare.

/SrcDatabaseName

/TargetDatabaseName

For ConnectionBased providers, this is the connection string

/SrcDisplayName

/TargetDisplayName

For ConnectionBased providers, this is the name of the database

/SrcUserName

/TargetUserName

This is the title used in the schema compare editor for this source or target

/SrcPassword

/TargetPassword

For ProjectBased providers, this is the name of the project. This project must be open in the Solution Explorer.

I have two named SQL Server 2008 instances on my box – SQL2008_1 and SQL2008_2. The first instance has a database named ‘Drake’ and the other ‘Josh’. I’m using windows authentication, so no username or password is required.  A Data Compare session can be launched by typing the following command into the Command Window

Data.NewDataComparison /SrcServerName .\SQL2008_1 /SrcDatabaseName Drake /SrcDisplayName Drake /TargetServerName .\SQL2008_2 /TargetDatabaseName Josh /TargetDisplayName Josh

If differences are available, I can now use the command “Data.DataCompareExportToFile [filename]” to create a data update script. When I execute “Data.DataCompareExportToFile C:\JoshUpgrade.sql" in the Command Window a data upgrade script will be created.

Conclusion

At this point I’ve illustrated how to use the Import Script, Schema Compare and Data Compare DTE commands. I hope you’re starting to see the flexibility this provides for authoring your own addins, packages or applications tailored to your specific requirements.

- Patrick Sirr

“DataDude” Programmer

Posted: Saturday, November 22, 2008 8:46 AM by psirr

Comments

Data Dude said:

Patrick Sirr , one of the key developers in our team started his own blog. If you want to learn about

# November 22, 2008 2:00 PM

Data Dude said:

Finally the moment is there, the final version of the Visual Studio Team System 2008 Database Edition

# November 25, 2008 9:19 PM

SQL Server vu par Christian Robert said:

Ca n'est pas encore Visual Studio 2010, mais pour la partie base de données, on s'en approche à grand

# December 1, 2008 4:26 PM

paulsmith68 said:

Thanks for this post; I'm surprised how little documentation is out there on scripting out Visual Studio's Schema Compare and Data Compare.

Is there really no way to script a list of tables/views to use in a Data Comparison? I'd love to automate reference data synchronization as part of my build process, since it's one of the last things left that we actually have to do by hand.

Using bit of automation on top of VS's Data Compare to accomplish this would be ideal, if it were possible.

# June 24, 2009 3:15 PM

bahill said:

Hi Paul,

No, sorry, there is not a way to select specific tables/views through DTE.

You can automate the synchronization of your reference data as a part of the deploy process by including the sync in the database project's post deployment script.  The upside to this is the reference data is source code controlled.  Check out this example and some of the other resources others have suggested: http://blogs.msdn.com/bahill/archive/2009/04/01/maintaining-and-synchronizing-your-reference-data.aspx

Thanks.

Thanks.

# June 26, 2009 1:31 AM
Anonymous comments are disabled
Page view tracker