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 2000 Forums
 Import/Export (DTS) and Replication (2000)
 Adding Primary Key Field

Author  Topic 

JacobPressures
Posting Yak Master

112 Posts

Posted - 2005-09-23 : 12:04:13
The original table has dublicate information because it was not properly normalized. There can be several different primary key values for the same item. For example:

1 GoodBookTitle

2 GoodBookTitle

3 PracticalBookTitle

4 GoodBookTitle

5 PracticalBookTitle

6 OkBookTitle

I leave the primary key out of the query and use the group by statement to eliminate the duplicates. The Import/Export Wizard is able to save the information to the destination table however, it doesn't add a unique primary key field. If i check the box "Enable identity insert" it does not add a primary key field. If i remove the check it still does not. If i create the table in advance with a primary key field it gives me an error saying it cannot insert data with a null primary key value.

So, i can get the results into the table but i can't add a primary key to the table either while i copy the info into the destination table or afterwards.

Can anyone help me?

ravilobo
Master Smack Fu Yak Hacker

1184 Posts

Posted - 2005-09-23 : 12:33:13
1. export the data using DTS to a normal Table.
2. remove the duplicate values.
3. Create PK.

------------------------
I think, therefore I am - Rene Descartes
Go to Top of Page

JacobPressures
Posting Yak Master

112 Posts

Posted - 2005-09-23 : 12:55:37
I wanted to learn to use DTS first but i experienced a problem and i was told it was easier to use the import/export wizard. Now i feel i need to go back and learn to use DTS.

I will look into it and try it. Thanks!
Go to Top of Page
   

- Advertisement -