Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in
Home       Members    Calendar    Who's On

Add to briefcase

SQL Server - Merging Two Tables with PK on both tables Expand / Collapse
Posted Monday, October 22, 2012 2:01 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, April 8, 2016 4:49 PM
Points: 3, Visits: 140

I had a situation where we have two different DBs with Table-A (on DB1) & Table-B (on DB2). I have to merge both tables to a single new table (Table-C on DB1 or DB2 or NewDB).

Here Table-A & Table-B are PK enabled & need the same on Table-C. Just want to know few suggestions/approaches on how to handle PK conflicts while in merging process.

Brief questions:
1) Approaches/suggestions to merge these tables.
2) Approaches/suggestions to handle PK conflict records during this merge process.

Kindly provide detailed explanation in doing this.
Post #1375713
Posted Tuesday, October 23, 2012 5:50 AM



Group: General Forum Members
Last Login: Tuesday, July 19, 2016 4:34 AM
Points: 2,850, Visits: 4,076
your requirement is basically De-normalization approach. First remove duplicate coluimn some time you need to merge the coluimn (concatenation of data like name = first name + last name )

for Pk u need to see how data willl be uniquely defined means what are the columns good for PK candidate its not neccessary that old two table's coljumns will be used for PK.

and for detail , post ur table defintion

I work only to learn Sql Server...though my company pays me for getting their stuff done
Post #1375981
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse