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)
 Import into a table with PK

Author  Topic 

CanadaDBA

583 Posts

Posted - 2005-05-23 : 00:33:40
I want to import from a text file into a table with a Primary Key. One way is to drop the PK, then import data and then ALTER table and add the PK to the table. How it is possible to have the PK in the table and do the import?

Canada DBA

derrickleggett
Pointy Haired Yak DBA

4184 Posts

Posted - 2005-05-23 : 01:07:58
Man, you're just posting this on all the forums, aren't you?

(by myself)

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.
Go to Top of Page

CanadaDBA

583 Posts

Posted - 2005-05-23 : 01:18:20
Hey, I like both sql-server-performance and sqlteam forums and I post my questions in both of them and I get differeint ideas.
quote:
Originally posted by derrickleggett

Man, you're just posting this on all the forums, aren't you?

(by myself)

MeanOldDBA
derrickleggett@hotmail.com

When life gives you a lemon, fire the DBA.



Canada DBA
Go to Top of Page

amitja
Starting Member

7 Posts

Posted - 2005-06-06 : 08:52:42
Set Identity_insert on before import and then set it back off on the table you are trying to import.

Set IDENTITY_INSERT [Tab Name] ON
Insert into [Tab Name]....
Set IDENTITY_INSERT [Tab Name] OFF
Go to Top of Page
   

- Advertisement -