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.
| Author |
Topic |
|
pvn80
Starting Member
5 Posts |
Posted - 2005-07-01 : 14:55:33
|
| MS SQL Server 2000Windows Server 2000I have a few hundred txt files I need to import into a table, each txt file has approximately 3 to 5 thousand rows space delimited about 200 columns. If I import one file at a time everything goes fine, if I use "type *.* >c:\somefilename.txt" to concactinate the text files into one, I always get a Primary Key violation on the last row that needs to be imported. I have gone through the files and there are no PK violations, by the way I am using a date time stamp as the PK for each row. example "5/8/2005 11:59:49 PM". I have done this with 5 or 6 other tables and everything has gone fine. any help on this would be very apreciated.Thank you all in advancePaul |
|
|
nosepicker
Constraint Violating Yak Guru
366 Posts |
Posted - 2005-07-01 : 15:09:46
|
| Maybe blank lines at the end of some files are causing this problem? |
 |
|
|
pvn80
Starting Member
5 Posts |
Posted - 2005-07-01 : 15:53:24
|
| Nope I opened the txt file and even deleted the last few rows. still same error |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-07-01 : 16:30:18
|
| Import the data into a staging table that is an exact duplicate of the real table minus the primary key constraint. Check for duplicates in the staging table. Here's an example duplicate query:SELECT Column1, COUNT(*)FROM Table1GROUP BY Column1HAVING COUNT(*) > 1What does this query return?Tara |
 |
|
|
|
|
|