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 123»»»

Comparision of tables in two instances Expand / Collapse
Author
Message
Posted Wednesday, March 20, 2013 2:12 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, December 4, 2014 4:34 AM
Points: 233, Visits: 739
Am having two instances A and B, in that having a table called students in two databasess, but the records are not in match,

i want to retrieve records which are having in "A" database and not having in "B" database.

Instance : A
Database : Students
Table : Stud_Info

Instance : B
Database : Stud
Table : Stud_Info.
Post #1433051
Posted Wednesday, March 20, 2013 2:27 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 6:13 AM
Points: 3,348, Visits: 3,644
You need join your tables with a left join. This will shows which records are in one table but not in the other.

-------------------------------
Posting Data Etiquette - Jeff Moden
Smart way to ask a question

There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
I would never join a club that would allow me as a member - Groucho Marx
Post #1433058
Posted Wednesday, March 20, 2013 2:37 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, December 4, 2014 4:34 AM
Points: 233, Visits: 739
Hi Team,

Sample query Please........
Post #1433063
Posted Wednesday, March 20, 2013 3:19 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 6:13 AM
Points: 3,348, Visits: 3,644
select cola1,cola2,colb1,colb2 from tablea left outer join tableb on cola1 = colb1 where colb1 is null

Sample query.

Two points:-
This could be more accurate if you could provide table structure (see first link in my signature).
You need to understand this if you want to enhance your skills this linkhttp://msdn.microsoft.com/en-gb/library/ms187518(v=sql.105).aspx provides more information. The same information is also in Books on line


-------------------------------
Posting Data Etiquette - Jeff Moden
Smart way to ask a question

There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
I would never join a club that would allow me as a member - Groucho Marx
Post #1433076
Posted Wednesday, March 20, 2013 3:22 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, December 4, 2014 4:34 AM
Points: 233, Visits: 739
Am using below query, but not executing,


select * from Stud_Info
left inner join SVSINST\SR2002.students.stud_Info

Please help me in query building....
Post #1433077
Posted Wednesday, March 20, 2013 3:34 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 6:13 AM
Points: 3,348, Visits: 3,644
You have an error in your query.
Please re-read my sample query and the link I posted - you might see the error then.


-------------------------------
Posting Data Etiquette - Jeff Moden
Smart way to ask a question

There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
I would never join a club that would allow me as a member - Groucho Marx
Post #1433085
Posted Wednesday, March 20, 2013 3:38 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, December 4, 2014 4:34 AM
Points: 233, Visits: 739
Query Looks great,

But i want to retrieve unmatched records from two seperate instances.

Instance : A
Database : Students
Table : Stud_Info

Instance : B
Database : Stud
Table : Stud_Info.

output should be displayed from stud_info tables from two databases/instances
Post #1433090
Posted Wednesday, March 20, 2013 3:41 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 6:13 AM
Points: 3,348, Visits: 3,644
What is the query you are using at present?

-------------------------------
Posting Data Etiquette - Jeff Moden
Smart way to ask a question

There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
I would never join a club that would allow me as a member - Groucho Marx
Post #1433092
Posted Wednesday, March 20, 2013 3:46 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Thursday, December 4, 2014 4:34 AM
Points: 233, Visits: 739
select * from Stud_Info
left inner join SVSINST\SR2002.students.stud_Info
Post #1433095
Posted Wednesday, March 20, 2013 3:52 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: 2 days ago @ 6:13 AM
Points: 3,348, Visits: 3,644
Minnu (3/20/2013)
select * from Stud_Info
left inner join SVSINST\SR2002.students.stud_Info

Left inner join ?
When I try to run left inner join I get :-
Msg 156, Level 15, State 1, Line 2
Incorrect syntax near the keyword 'INNER'.

Please re-read my very basic example and the example in books on line.

I am sorry if it sounds like I am labouring the point but I won't be supporting you system - you will be - you need to understand this.


-------------------------------
Posting Data Etiquette - Jeff Moden
Smart way to ask a question

There are naive questions, tedious questions, ill-phrased questions, questions put after inadequate self-criticism. But every question is a cry to understand (the world). There is no such thing as a dumb question. ― Carl Sagan
I would never join a club that would allow me as a member - Groucho Marx
Post #1433101
« Prev Topic | Next Topic »

Add to briefcase 123»»»

Permissions Expand / Collapse