Text file Import

  • I am currently trying to import a text file into sql server. I want to be able read the text file and based on certain headers import the data into various tables. The format of the file is as follows:

    [CODES]

    AX1 !AX1 !MAXIMUM ! !X! !

    LEVEL_0 !LEVEL_0 !MAXIMUM !X! ! !

    LEVEL_1 !LEVEL_1 !MAXIMUM !X! ! !

    LEVEL_2 !LEVEL_2 !MAXIMUM !X! ! !

    LEVEL_3 !LEVEL_3 !MAXIMUM !X! ! !

    LEVEL_4 !LEVEL_4 !MAXIMUM !X! ! !

    LEVEL_5 !LEVEL_5 !MAXIMUM !X! ! !

    LEVEL_6 !LEVEL_6 !MAXIMUM !X! ! !

    LEVEL_7 !LEVEL_7 !MAXIMUM !X! ! !

    LEVEL_8 !LEVEL_8 !MAXIMUM !X! ! !

    LEVEL_9 !LEVEL_9 !MAXIMUM !X! ! !

    [FORMULAS]

    CHARTDSM !Default DSM Chart Logic !MAXIMUM !A! !

    DYNVIEWACCTS !Dynamic View Accts !MAXIMUM !A! !

    CONSOL !Default Consolidation Logic !MAXIMUM !C! !

    CHART !Default Chart Logic !MAXIMUM !A! !

    SRPLOG !SRPLOG !MAXIMUM !A! !

    TRANS !Default Translation Logic !MAXIMUM !T! !

    NWMNTH !New Month Logic !MAXIMUM !A! !

    [CATEGORY]

    ACT10INR !Actual 2010 Input Region !SC_C_ACT10INR !M!YTD! !12!JAN!2010!

    ACT10INN !Actual 2010 Input Non-Client !SC_C_ACT10INN !M!YTD! !12!JAN!2010!

    ACT10INM !Actual 2010 Input Manufacturing !SC_C_ACT10INM !M!YTD! !12!JAN!

    ACT10INB !Actual 2010 Input Non-Core !SC_C_ACT10INB !M!YTD! !12!JAN!2010!

    ACT10R !Actual 2010 Region !SC_C_ACT10R !M!YTD! !12!JAN!2010!

    ACT10N !Actual 2010 Non-Client !SC_C_ACT10N !M!YTD! !12!JAN!2010!

    ACT10M !Actual 2010 Manufacturing !SC_C_ACT10M !M!YTD! !12!JAN!2010!

    With the text file above I would like to import the data under the CODES heading into a table called codes, likewise for the data under FORMULAS and CATEGORY headings. If possible I would like to avoid using a programming language. I am also implementing this in both SQL 2005 and SQL2K.

  • I dont think it is possible without Script (C# or VB.NET) language.

    However you can create a staging table and load the data into that table. Once you get the data, you can move the data to respected tables by finding the row number of codes.

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply