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)
 Importing Text Files with no column headings

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-10-28 : 08:37:53
Graham writes "Hi,

I am importing a comma delimited text file using the SELECT * FROM WHERE TITLE='ABC'.

If Row 1 of the Text File Contains TITLE it finds all of the references in that Column to ABC, Perfect!

However, the text file (export from another application), which is 60MB doesn't contain the heading (unless I put it in) I can't get the WHERE bit to work without a Heading...

Is there a way to refer to the column you want to search instead?

Thanks

Graham."

AjarnMark
SQL Slashing Gunting Master

3246 Posts

Posted - 2003-10-28 : 11:45:15
OK, I'm confused here. You talk about importing a text file, and then your question is about doing a SELECT statement? Where did you import the text file to? How are you importing it using SELECT * as you talk about? Are you using DTS? BCP? BULK INSERT?

Is this a one-off or a repeating issue? If it's a one-off why not just go add a header row of your own? If it's repeating, work with the export from the other application to get your header row.

--------------------------------------------------------
Visit the SQLTeam Weblogs at [url]http://weblogs.sqlteam.com[/url]
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2003-10-28 : 12:41:23
If your text file doesn't contain the headings, then you need to create a staging table. Create a table that looks like your destination table or at least like your text file. Import the data into this staging table. Then run T-SQL to get the data from your staging table into the destination table. Then delete the rows from the staging table.

Tara
Go to Top of Page
   

- Advertisement -