Exforsys
+ Reply to Thread
Results 1 to 3 of 3

how to transfer from flatfiles to sql server DB

This is a discussion on how to transfer from flatfiles to sql server DB within the SQL Server forums, part of the Database category; Hi I want to know how to transfert data from flatfiles to sqlserver DB explain with an example Manual procedure ...

  1. #1
    rite2sekhar is offline Junior Member Array
    Join Date
    Sep 2004
    Answers
    10

    how to transfer from flatfiles to sql server DB

    Hi
    I want to know how to transfert data from flatfiles to sqlserver DB

    explain with an example Manual procedure not by im port method


    Urgent Plz

    Regds

    Last edited by rite2sekhar; 03-07-2005 at 08:59 AM.

  2. #2
    admin's Avatar
    admin is offline Administrator Array
    Join Date
    Mar 2005
    Location
    New York, USA
    Answers
    58
    Right click on the database and you should see an option to import , select that, then you will be given options about the data source, select text file from that list and browse to your file. click next to select the destination db and the trabsformations.

    if you have column names, you can check the box in wizard, import uses them as column names.


  3. #3
    sanereddy is offline Member Array
    Join Date
    Nov 2004
    Answers
    85
    You can use the bulk insert creating the format files with the layout of your import file....

    search for bulk insert in books online, the documentation is pretty good.


    here is the sample format file and the stored procedure to read the file and load in SQL Server ....


    Hope this helps.

    Format File : save as text file and keep on the server some where to be accessable by SQl Server.

    sample.fmt

    8.0
    5
    1 SQLCHAR 0 1 "" 1 FIELD1 ""
    2 SQLCHAR 0 5 "" 2 FIELD1 ""
    3 SQLCHAR 0 4 "" 3 FIELD1 ""
    4 SQLCHAR 0 4 "" 4 FIELD1 ""
    5 SQLCHAR 0 10 "\r\n" 5 FIELD1 ""

    This is the stored procedure which reads the import file and uses the format file , loads the data in toe sample_data table.

    CREATE procedure sample_load as

    BULK INSERT northwind..Sample_data FROM 'F:\Microsoft SQL Server\sample.txt'
    WITH (
    FORMATFILE = 'F:\Microsoft SQL Server\sample.fmt'
    )



    Hope this helps.


    •    Sponsored Ads



Latest Article

Network Security Risk Assessment and Measurement

Read More...