Solved

Transfer data using SSIS. Convert between int and guid.

Posted on 2007-03-23
4
1,450 Views
Last Modified: 2013-11-30
Hello,

I'm in the process of moving data from one database to another.  Both are Microsoft sql 2005 databases.  I planning on using SSIS to do this but have run into a problem.  Since the source database uses int for its primary key and the destination database uses guid for its primary key how can I preserve relationships between tables.  

I am fairly new to SSIS but feel comfortable with straight forward data transfer between tables.  Any advice/help would be greatly appreciated.

Thanks for the help in advance.
Dean.
0
Comment
Question by:drimando
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 8

Expert Comment

by:navalarya1982
ID: 18785766
can you share the query you are using for data transfer?
0
 

Author Comment

by:drimando
ID: 18786230
Thanks for the response.

I actually don't have a query to share as this is where I need help.  I'm looking for some guidance as to how to go from a database that uses OID to one that uses GUID and still maintain table relationships.  

Example:

Source Database has Customer, Project and Contact Tables with the following fields:
Customer Table: OID, CustomerName, ContactID, ProjectID
Contact Table: OID, ContactName
Project Table: OID, ProjectName

Destination Database has Customer, Project and Contact Tables with the following fields:
Customer Table: GUID, CustomerName, ContactGUID, ProjectGUID
Contact Table: GUID, ContactName
Project Table: GUID, ProjectName

How do you move data between the databases and still maintain the corresponding links to the Contact and Project Tables?

Thanks.
0
 
LVL 8

Accepted Solution

by:
drydenhogg earned 500 total points
ID: 18792472
I can't think of an easy / automatic way to do it, it is possible although it is going to take some manual work / thinking through the issue.

In the destination database add an integer field to hold the old ID and import the data generating GUID's as you go along where necessary. Then you will need to run updates to rematch the data based on the ID's, when you have processed each table and the ID field, you can alter the table and drop the old ID column.

If the tables form a natural hierarchy you can use the lookup IS object to perform this on the fly instead of doing it manually, however if you have any references which end up being a bit circular then you have to make a decision which table to bring over first, bring the integer ID with it, and then do the rest from there in the right order (reverse up the hierarchy).

hth.
0
 

Author Comment

by:drimando
ID: 18792535
Hi drydenhogg,

I thought of a solution along these lines before posting but wasn't sure if there was an easier way.  I was hoping there would be...

Thanks for your help.
0

Featured Post

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

726 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question