Solved

Transfer data using SSIS. Convert between int and guid.

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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

758 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

22 Experts available now in Live!

Get 1:1 Help Now