how do i load a txt file into sql server database

Posted on 2009-05-18
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 500 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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

Let's review the features of new SQL Server 2012 (Denali CTP3). It listed as below: PERCENT_RANK(): PERCENT_RANK() function will returns the percentage value of rank of the values among its group. PERCENT_RANK() function value always in be…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

724 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