SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Query Analysis


Query Analysis

Author
Message
deepika_goyal
deepika_goyal
Valued Member
Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)

Group: General Forum Members
Points: 65 Visits: 117
Dear All,

Need some Suggestion.

I have two tables one is Master and other one is slave.

MY master table has some set of Data and slave tables contains data set from many slaves.

Here is the sample data

Master
No. Type Version Date
1 Sales V1.0 01/10/2012
2 Consumption V1.10 29/10/2012
3 Daily Needs V1.01 13/08/2011
4 Overall V2.01 01/09/2012



Slave
Code No. Type Version Date
S001 1 Sales V1.0 01/10/2012
S001 2 Consumption V1.10 29/10/2012
S001 3 Daily Needs V1.01 13/08/2011
S001 4 Overall V2.01 01/09/2012
S001 5 Electricity V5.01 18/10/2012
S002 1 Sales V1.0 01/10/2012
S002 2 Consumption V1.10 15/10/2012
S002 3 Daily Needs V1.1000 13/08/2011
S003 1 Sales V1.0 01/10/2012
S003 2 Consumption V1.10 29/10/2012
S003 4 Overall V2.01 01/09/2012
S003 3 Daily Needs V1.01 13/08/2011
S003 4 Overall V2.01 01/09/2012
S003 5 Electricity V5.01 18/10/2012


Now, i have to compare Master with slave and then Slave with Master.

Here are conditions.

1. IF my master and slave matches then report says MATCH
2. IF my master and slave doesnt matches then report says MISMATCH
3. IF my Master contains more data than slave then report says Missing at Slave
4. IF my slave contains more data than Master then report says Missing data at Master.


i know how to get the data, but i want quickest way as my slave table contains millions of record, i want my process to be very quick.


Summarization of test cases.

Final Report
Master Slave Status
Code No. Type Version Date Version Date
S001 1 ALL Match
S002 2 Daily Needs V1.01 13/08/2011 V1.10013 /08/2011 Mismatch
S002 3 Daily Needs V1.01 13/08/2011 V1.1000 13/08/2011 Mismatch
S002 4 Overall V2.01 01/09/2012 V5.01 18/10/2012 Missing in Slave
S003 5 Electricity V5.01 18/10/2012 Missing in Master


PLease let me know if anybody have quick way to do it.

thanks


Regards.
Deepika
deepika_goyal
deepika_goyal
Valued Member
Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)

Group: General Forum Members
Points: 65 Visits: 117
Hello!!,

NO body has replied on thiss.

Please give some suggestion.



Thanks!!
Dave Ballantyne
Dave Ballantyne
SSCertifiable
SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)

Group: General Forum Members
Points: 7276 Visits: 8370
IF you show your code for the solution and the execution plan then you may get some suggestions on optimization.



Clear Sky SQL
My Blog
deepika_goyal
deepika_goyal
Valued Member
Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)

Group: General Forum Members
Points: 65 Visits: 117
Thanks Dave for your reply..

Still i have to Code, i want to know good approach so that i can start my development.

please let me know any way.

thanks a lot
Dave Ballantyne
Dave Ballantyne
SSCertifiable
SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)SSCertifiable (7.3K reputation)

Group: General Forum Members
Points: 7276 Visits: 8370
This sounds like a relational division problem,ie some rows, equal rows, more rows...

Joe Celko has done a good write up on the subject, http://www.simple-talk.com/sql/t-sql-programming/divided-we-stand-the-sql-of-relational-division/



Clear Sky SQL
My Blog
deepika_goyal
deepika_goyal
Valued Member
Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)Valued Member (65 reputation)

Group: General Forum Members
Points: 65 Visits: 117
Thanks Dave!!:-):-)

will go through it.


Regards,
Deepika
ChrisM@Work
ChrisM@Work
SSC-Forever
SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)SSC-Forever (42K reputation)

Group: General Forum Members
Points: 42194 Visits: 20012
deepika_goyal (10/11/2012)
Hello!!,

NO body has replied on thiss.

Please give some suggestion.

Thanks!!


Hello

You are likely to get a much faster response if you provide DDL for your sample data. Here's your 'master' table, can you do the same with the 'slave' table? Make sure it runs without errors and that the data is correct before you post it. Thanks.

CREATE TABLE #Master ([No] INT, [Type] VARCHAR(20), [Version] VARCHAR(10), [Date] DATE)
SET DATEFORMAT DMY
INSERT INTO #Master ([No], [Type], [Version], [Date])
SELECT 1, 'Sales', 'V1.0', '01/10/2012' UNION ALL
SELECT 2, 'Consumption', 'V1.10', '29/10/2012' UNION ALL
SELECT 3, 'Daily Needs', 'V1.01', '13/08/2011' UNION ALL
SELECT 4, 'Overall', 'V2.01', '01/09/2012'

SELECT * FROM #Master



“Write the query the simplest way. If through testing it becomes clear that the performance is inadequate, consider alternative query forms.” - Gail Shaw

For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Exploring Recursive CTEs by Example Dwain Camps
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search