Solved

how do i load a txt file into sql server database

Posted on 2009-05-18
4
562 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 14

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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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…
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

707 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

12 Experts available now in Live!

Get 1:1 Help Now