Thursday, March 8, 2012

Compare data between two views on two different databases

How can I compare data returned by two views on two different
databases? I want to compare column by column or the whole dataset. I
need to do that in query.
Thanks
Thanks for the quick response, but it doesn't work for me - hopefully
it is just me.
If I run this on sql query analyzer
Except({Canada, [British Columbia], Mexico, [British Columbia], USA,
Washington}, {Canada, Mexico, California})
I get [Microsoft][ODBC SQL Server Driver]Syntax error or access
violation
I think Except only works for enterprise version of sql server.
And yes, by the way, I just want the exceptions - the rows that don't
appear in both views.
On May 1, 6:37 pm, "David Portas"
<REMOVE_BEFORE_REPLYING_dpor...@.acm.org> wrote:
> "Sehboo" <MasoodAd...@.gmail.com> wrote in message
> news:1178058288.926031.204610@.h2g2000hsg.googlegro ups.com...
>
> It's not difficult tocomparethem but you haven't specified exactly what
> result you would like to see from the comparison. Maybe you just want the
> exceptions - the rows that don't appear in both views. In that case:
> (SELECT *
> FROM DB01.dbo.view1
> EXCEPT
> SELECT *
> FROM DB02.dbo.view2)
> UNION
> (SELECT *
> FROM DB02.dbo.view2
> EXCEPT
> SELECT *
> FROM DB01.dbo.view1);
> --
> David Portas,SQLServerMVP
> Whenever possible please post enough code to reproduce your problem.
> Including CREATE TABLE and INSERT statements usually helps.
> State what version ofSQLServeryou are using and specify the content
> of any error messages.
> SQLServerBooks Online:http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
> --

No comments:

Post a Comment