Solved

how do i load a txt file into sql server database

Posted on 2009-05-18
4
564 Views
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' 

    WITH 

    ( 

        FIELDTERMINATOR = ',', 

        ROWTERMINATOR = '\n' 

    )

Open in new window

testNuo.txt
0
Comment
Question by:manivineet
  • 2
4 Comments
 
LVL 15

Expert Comment

by:rob_farley
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.

Rob
0
 
LVL 7

Expert Comment

by:thiyaguk
ID: 24409744
0
 
LVL 31

Accepted Solution

by:
RiteshShah earned 500 total points
ID: 24409746
have a look at screen shot.
1.JPG
2.JPG
3.JPG
4.JPG
5.JPG
6.JPG
0
 
LVL 31

Expert Comment

by:RiteshShah
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
0

Featured Post

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

Question has a verified solution.

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

Suggested Solutions

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.
Viewers will learn how the fundamental information of how to create a table.

929 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

10 Experts available now in Live!

Get 1:1 Help Now