Click here to monitor SSC

James Moore

Divisional Manager for SQL Tools - Red Gate Software

SQL Data Compare: Comparing Views

Published Tuesday, November 22, 2005 10:16 AM

In case you haven’t come across this before you can actually compare two views in SQL Data Compare. The only pre-requisite is that the view has an index defined on it. As an example lets create and compare an indexed view on pubs.

First we must create the view with the schema binding option:

CREATE VIEW cheap_titles WITH SCHEMABINDING as
SELECT titles.title_id, 
	  titles.title, 
	   titles.type, 
	 titles.pub_id, 
	  titles.price, 
	titles.advance, 
	titles.royalty 
FROM dbo.titles WHERE price < 5.00
GO

We now need to create the index on the view:

CREATE UNIQUE CLUSTERED INDEX cheap_titles_unique ON cheap_titles(title_id)

When we now use SQL Data Compare to compare two databases with this indexed view defined we are given the option of including it in the comparison.

by James

Comments

 

Douglas Reilly said:

I presume the index must be a unique index?
November 22, 2005 2:57 PM
New Comments to this post are disabled
Latest articles
Checking Out SQL Backup Pro 7’s New Automatic Backup Verification
 Wouldn't it be great to offload the daily chore of checking the integrity of your production... Read more...

Chuck Lathrope: DBA of the Day
 Chuck Lathrope was a finalist for the Exceptional DBA of the Year award in 2009. We contacted him to... Read more...

Backups, What Are They Good For?
 Pixar recently confessed, in an engaging video, that Toy Story 2 was almost lost due to a bad backup,... Read more...

C# Async: What is it, and how does it work?
 The biggest new feature in C#5 is Async, and its associated Await (contextual) keyword. Anybody who is... Read more...

SQL Server 2012 AlwaysOn
 SQL Server AlwaysOn provides a high-availability and Disaster-recovery solution for SQL Server 2012. It... Read more...