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

Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

762 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