Bulk Insert SQL 2005 txt file

Hi,

I have a text file, with data as follow

"ID","name"
"1","John"

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:

9.0
3
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?

Thanks.
ezzadinAsked:
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
http://blogs.msdn.com/b/sqlserverfaq/archive/2010/02/04/how-to-remove-unwanted-quotation-marks-while-importing-a-data-file.aspx
0

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:
Thanks.
0
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.