Bulk Insert SQL 2005 txt file


I have a text file, with data as follow


BULK INSERT dbo.table1 FROM 'C:\file.txt' WITH ( FIELDTERMINATOR = ',', ROWTERMINATOR = '\n', FORMATFILE='C:\table1.fmt' )

Open in new window

Here is the format file:

1       SQLINT        0       4       ""         1     id1          ""
2       SQLCHAR       0       35      "\",\""    2     ID           SQL_Latin1_General_CP1_CI_AS
3       SQLCHAR       0       50      "\r\r\n"   3     Name         SQL_Latin1_General_CP1_CI_AS

Open in new window

When I use the above Bulk Insert, the data is being imported as follow:

id1      ID                    Name
1           ,"name" "1       Smith"

Identity Specification is set to Yes for id1.

I have also tried FIELDTERMINATOR = '","'

What would be the best way to import the data without having to remove " from the file?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Eugene ZCommented:
please try this way
How to remove unwanted Quotation Marks while importing a data file

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
ezzadinAuthor Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server 2005

From novice to tech pro — start learning today.