Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

problems when importing a text file 1

Status
Not open for further replies.

ska4reak

Technical User
Oct 19, 2002
20
US
Hello everybody,
I have a table called HTML that looks as follows:
A B
int ntext

A is the PK and my HTML table has a 1 to 1 relationship with another table with the same PK. HTML already has data on it. I cannot see any data on column B. All i see is this text - <LONGTEXT>. After some research I found out that I'd have to export this table into a text file to see that data on it. I did the exporting. I saw the data. I made changes to the data. And I tried to import it back. And there lies the problem.
How do I change the column names from Col001, Col002 to A, B like my HTML table above. How do I tell SQL 2000 to overwrite all data on the HTML table after the import? Why does SQL 2000 tell me that due to relationship constraints it cannot duplicate data?
Any help would be greatly appreciated.
 
You have a few things going on here ...

First ... If your text file has the column names Col001, Col002 then remove them from the text file OR as you are doing the Import, your &quot;Select File Format&quot; screen gives you a check box option of &quot;first row has column headers&quot;. If there are NO column headers in your text file, the Col001 is the default name DTS is using to identify the field in that position. As long as you have the fields in your text file lined up in the same order as your table, the names really do not matter.

We are now at the sticky part of the PK issue. For futire reference, during the Import operation, a screen by the name of &quot;Select Source Table and Views&quot; will be presented. If you click on the &quot;Transform&quot; tab, you will see it will bring up transformation options and one of them being ...
&quot;Drop and Recreate Table&quot;. This will drop/create the table then import the text file data, in this case, into the table.

However ... I do not believe you will be able to do this due to the key contraints. As I see it, you have 2 options.

1. drop the key contraint
truncate the table
run the DTS import
recreate the constraint

2. Import the text file into a work table
perform an update of the HTML table against the work
table based on PK.

The reason you are seeing the error message of dup data is that you ARE trying to import the same data, based on the PK, back into the table.

Thanks

J. Kusch
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top