Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Database dump

Author  Topic 

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2010-07-09 : 08:33:31
I am going to be moving data from an Oracle database to a MSSQL Database. My question is on primary keys. So lets say I need to copy data from a Oracle db that has a primary key into the MSSQL table that has a primary key. How is this done?

Dave
Helixpoint Web Development
http://www.helixpoint.com

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-07-09 : 09:32:51
it won't affect your data copy one bit.

do you mean an auto-incrementing (identity) field? if that's what you mean, then SET IDENTITY INSERT <table name> ON; import the data and then SET IDENTITY INSERT <table name> OFF;
Go to Top of Page

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2010-07-09 : 10:34:16
well. Let say we have a SQL table TABLEA that has 2 fields ID and NAME. ID is has an identity set and is the primary key. In the Oracle table, I have 2 fields IDVAL and NAMEVAL. I need to copy the IDVAL key to the ID key along with the names. Do I do what you said above?

Dave
Helixpoint Web Development
http://www.helixpoint.com
Go to Top of Page

russell
Pyro-ma-ni-yak

5072 Posts

Posted - 2010-07-09 : 11:43:40
how are you copying the data? if using SSIS, you can simply tick the enable identity insert checkbox.

if using t-sql you'll need to enable it like i showed above.
Go to Top of Page
   

- Advertisement -