Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

SQL insert into statement from text file

Posted on 2011-03-25
4
Medium Priority
?
303 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
ID: 35218251
I believe that a semi colon is a special character in SQL.  Can you change the delimiter to something else?
0
 
LVL 39

Expert Comment

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

Accepted Solution

by:
Ephraim Wangoya earned 2000 total points
ID: 35218295

use BULK insert instead

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

Author Closing Comment

by:asmyatt
ID: 35218380
Works good. Thanks
0

Featured Post

Configuration Guide and Best Practices

Read the guide to learn how to orchestrate Data ONTAP, create application-consistent backups and enable fast recovery from NetApp storage snapshots. Version 9.5 also contains performance and scalability enhancements to meet the needs of the largest enterprise environments.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…

886 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