Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Query Analysis Expand / Collapse
Author
Message
Posted Thursday, October 11, 2012 5:17 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Saturday, December 29, 2012 1:46 AM
Points: 23, 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


Post #1371366
Posted Thursday, October 11, 2012 11:21 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Saturday, December 29, 2012 1:46 AM
Points: 23, Visits: 117
Hello!!,

NO body has replied on thiss.

Please give some suggestion.



Thanks!!
Post #1371891
Posted Friday, October 12, 2012 12:06 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, September 9, 2014 2:06 AM
Points: 1,768, Visits: 8,318
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
Kent user group
Post #1371899
Posted Friday, October 12, 2012 12:11 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Saturday, December 29, 2012 1:46 AM
Points: 23, 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
Post #1371902
Posted Friday, October 12, 2012 2:34 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Tuesday, September 9, 2014 2:06 AM
Points: 1,768, Visits: 8,318
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
Kent user group
Post #1371947
Posted Friday, October 12, 2012 3:40 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Saturday, December 29, 2012 1:46 AM
Points: 23, Visits: 117
Thanks Dave!!

will go through it.


Regards,
Deepika
Post #1371979
Posted Friday, October 12, 2012 3:49 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Thursday, December 18, 2014 1:43 AM
Points: 6,890, Visits: 14,254
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
Post #1371985
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse