Solved

Transfer data using SSIS. Convert between int and guid.

Posted on 2007-03-23
4
1,442 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
  • 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

Suggested Solutions

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
Viewers will learn how the fundamental information of how to create a table.

816 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

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now