Solved

SQL insert into statement from text file

Posted on 2011-03-25
4
292 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 38

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:
ewangoya earned 500 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

by Mark Wills Attending one of Rob Farley's seminars the other day, I heard the phrase "The Accidental DBA" and fell in love with it. It got me thinking about the plight of the newcomer to SQL Server...  So if you are the accidental DBA, or, simp…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.

813 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

16 Experts available now in Live!

Get 1:1 Help Now