Importing Textfiles into SQL Server 2000
- From: zwieback89
- Date: Mon, 28 Sep 2009 13:32:49 -0700
Hello,
Hi,
I have been unable to import a Text file into SQL Server 2000.
I have a Text file - Position.txt. When I open the file in textpad, here is what I see:
1. Each row is on a new line.
2. Each field is separated by a semi-colon.
3. The first line has the headers for the data.
4. At the end of the last field of the header column, I see a semi-colon.
5. All other rows have no commas at the end, just a new line separation. (except a good part of lines)
When I try to import the data from the textfile through a SQL Code (shown below), I get a message - "0 row(s) affected"
The data gets imported into Excel 2007 perfectly. I even tried converting the text file into an Excel file (.xls) and then importing it into SQL Server 2000. It worked fine. On looking into the file closely, some of the rows have semi-colon at the end of the row while some does not have. It seems that the data is truly not formatted in the right way.
How can I import the file into SQL Server 2000?
My table structure is as follows:
CREATE TABLE [Quota].[dbo].[Position] (
[# Position Name] nvarchar (255) NULL,
[Effective Start Date] datetime NULL,
[Description] nvarchar (255) NULL,
[Incentive Start Date] datetime NULL,
[Incentive End Date] datetime NULL,
[Employee ID] nvarchar (255) NULL,
[Title] nvarchar (255) NULL,
[Person Name] nvarchar (255) NULL
)
--Import data into the Position Table from the Position.txt file
BULK INSERT Position
FROM 'C:\Sales_Ranking\Position.txt'
WITH
(
FIRSTROW = 2,
FIELDTERMINATOR = ';',
ROWTERMINATOR = '\n'
)
Any ideas,
Thanks.
EggHeadCafe - Software Developer Portal of Choice
WPF DataGrid Custom Paging and Sorting
http://www.eggheadcafe.com/tutorials/aspnet/8a2ea78b-f1e3-45b4-93ef-32b2d802ae17/wpf-datagrid-custom-pagin.aspx
.
- Follow-Ups:
- Re: Importing Textfiles into SQL Server 2000
- From: Erland Sommarskog
- Re: Importing Textfiles into SQL Server 2000
- Prev by Date: Re: What happens to the underlying database when the transaction log gets full...
- Next by Date: Upgrading 2005 Express to 2008 Developer
- Previous by thread: What happens to the underlying database when the transaction log gets full...
- Next by thread: Re: Importing Textfiles into SQL Server 2000
- Index(es):
Relevant Pages
|