Solved

SQL insert into statement from text file

Posted on 2011-03-25
4
291 Views
Last Modified: 2012-05-11
Hi Experts,

I have an sql database table that contains three fields:  LoanNumber, Borrower, LoanProgram. I have a text file that contains three values per line with a semicolon as the delimiter. I'm trying to write an insert into statement that will add rows to the database from the text file. What's wrong with my statement below?  Thanks.
use DataEase

insert into LockData ('LoanNumber', 'Borrower', 'LoanProgram')
from 'c:\SPECPROG.txt' 
with (FieldTerminator = ';')

Open in new window

0
Comment
Question by:asmyatt
4 Comments
 
LVL 11

Expert Comment

by:willettmeister
Comment Utility
I believe that a semi colon is a special character in SQL.  Can you change the delimiter to something else?
0
 
LVL 38

Expert Comment

by:Aaron Tomosky
Comment Utility
If you use managent studio it has an import wizard that can do this.
0
 
LVL 32

Accepted Solution

by:
ewangoya earned 500 total points
Comment Utility

use BULK insert instead

BULK INSERT LockData
FROM 'c:\SPECPROG.txt'
WITH
(
   FIELDTERMINATOR =',',
   ROWTERMINATOR = '\n'
)
0
 
LVL 2

Author Closing Comment

by:asmyatt
Comment Utility
Works good. Thanks
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Foreword In the years since this article was written, numerous hacking attacks have targeted password-protected web sites.  The storage of client passwords has become a subject of much discussion, some of it useful and some of it misguided.  Of cou…
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

728 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now