Inserting RAW Data to Table with selected columns

  • Hi,

    Anyone can help me, on how to insert a RAW Data to a Table with selected columns. I need only the Column1 and Column3 to be inserted. Thanking you.

    TextFile : RawData.CSV

    ----------------------

    Column1,Column2,Column3

    1111111,AAAAAA,BBBBBBB

    2222222,AAAAAA,BBBBBBB

    3333333,XXXXXX,CCCCCC

    Table : RAWDATA

    -----------------

    Column1 int,

    Column2 varchar(10),

    Column3 varchar(10),

    Regards,

    FPalero

  • You can bulk insert into a temporary table and then select the columns you desire. Here is an example:

    DECLARE @TempTable TABLE

    (

    Column1 INT,

    Column2 VARCHAR(10),

    Column2 VARCHAR(10)

    )

    BULK INSERT @TempTable FROM 'Filepath'

    SELECT Column1, Column2

    FROM @TempTable

    As an alternative, I believe that you can use a format file to bulk insert directly into your desired table.

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

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