• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 307
  • Last Modified:

SQL insert into statement from text file

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
asmyatt
Asked:
asmyatt
1 Solution
 
willettmeisterCommented:
I believe that a semi colon is a special character in SQL.  Can you change the delimiter to something else?
0
 
Aaron TomoskySD-WAN SimplifiedCommented:
If you use managent studio it has an import wizard that can do this.
0
 
Ephraim WangoyaCommented:

use BULK insert instead

BULK INSERT LockData
FROM 'c:\SPECPROG.txt'
WITH
(
   FIELDTERMINATOR =',',
   ROWTERMINATOR = '\n'
)
0
 
asmyattAuthor Commented:
Works good. Thanks
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now