[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now


how do i load a txt file into sql server database

Posted on 2009-05-18
Medium Priority
Last Modified: 2012-06-21
i have a text file in which the files are in the following format (see attached text file)
now the original text file is 233 mb big

now I need to load that text file, without the surrounding inverted commas ("") on each file
how do i do it? so that when I load it, the data is in sync with the data types in the table

don't ask me to replace the inverted commas in the text file.
CREATE TABLE zztbNetworkSettlementExtract
    ChargeCode INT
    ,TransactionNumber VARCHAR(50) 
    ,NoOfCharges INT
    ,PreviousTransactionNumber VARCHAR(50)
    , TransactionDate DATETIME
    ,ChargeType VARCHAR(10)
    ,ChargeDescription VARCHAR(50)
    ,NMI VARCHAR(10) 
    ,CheckSumValue INT	
    ,TariffCode VARCHAR(3)
    , Note VARCHAR(250)
    , ChargeStartDate DATETIME
    , ChargeEndDate DATETIME
    , TariffCodeDesc VARCHAR(250)
    , ReadType VARCHAR(2)
    , TariffDescription VARCHAR(50)
    , Consumption FLOAT
    , UOM VARCHAR(4)
    , Rate FLOAT	
    , GSTExlAmt FLOAT	
    , GSTAmt FLOAT	
    , GST VARCHAR(1)
BULK INSERT zztbNetworkSettlementExtract
    FROM 'c:\file.txt' 
        FIELDTERMINATOR = ',', 
        ROWTERMINATOR = '\n' 

Open in new window

Question by:manivineet
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
LVL 15

Expert Comment

ID: 24409698
Try running the Import/Export Wizard. Go to Management Studio, right-click on your database, and choose "Import Data" from the Tasks menu.

There are plenty of options in there for handling the speech-marks.

LVL 31

Accepted Solution

RiteshShah earned 2000 total points
ID: 24409746
have a look at screen shot.
LVL 31

Expert Comment

ID: 24409761
once you have "TestNUO" table in SQL Server you can do something like below.

insert into zztbNetworkSettlementExtract
select REPLACE([column 0],'"',''),REPLACE([column 1],'"','').............from testnuo

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
I have a large data set and a SSIS package. How can I load this file in multi threading?
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

650 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