troubleshooting Question

2 or more tables

Avatar of muneerz
muneerz asked on
Microsoft SQL Server 2005
4 Comments1 Solution240 ViewsLast Modified:
comparing tables data between 2 databasesBookmark:Question: I have 2 databases which are identical( having 2 tables called tblhr(pc) and tblpm with  pn and pc coulmns)

database1 have table called tblhr and tblpm  having pc and pc and pn columns

database2 have table called tblhr having pc column and other table called tblpm have pc and pn columns

My task is to check database1 table columns i.e,pn (after joining the tblhr and tblpm) are matching with database2 tables

IF pn is present in database2 and also present in databse1 then i have to update the details in temp table i.e pn of database2 and pc of database1

IF pn does not exist in  database1 after comparing with database2 then need to insert pn values with incremental value i.e max of pc +1

How can i implement this on a stored procedure
comparing tables data between 2 databasesBookmark:Question: I have 2 databases which are identical( having 2 tables called tblhr(pc) and tblpm with  pn and pc coulmns)
 
database1 have table called tblhr and tblpm  having pc and pc and pn columns
 
database2 have table called tblhr having pc column and other table called tblpm have pc and pn columns
 
My task is to check database1 table columns i.e,pn (after joining the tblhr and tblpm) are matching with database2 tables
 
IF pn is present in database2 and also present in databse1 then i have to update the details in temp table i.e pn of database2 and pc of database1
 
IF pn does not exist in  database1 after comparing with database2 then need to insert pn values with incremental value i.e max of pc +1
 
How can i implement this on a stored procedure
Join the community to see this answer!
Join our exclusive community to see this answer & millions of others.
Unlock 1 Answer and 4 Comments.
Join the Community
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 4 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros