about Bulk Insert

  • hi

    I have a table whit 3 columns and i need to do a bulk insert from a Archive.Dat but this archive it only have one column to insert. (I have all ready the format file )

    the Archive.dat file file have this data.

    0003423

    0004849

    0004117

    0001771

    0001601

    0001602

    0001533

    0003546

    0006108

    The query of the bulk insert its like this

    BULK INSERT IngresoLector

    FROM 'C:\Archive.dat'

    WITH (FORMATFILE = 'C:\IngresoLector.Fmt');

    It works whit some thing like this:

    ,0003423,

    ,0004849,

    ,0004117,

    ,0001771,

    ,0001601,

    ,0001602,

    but the archive doesnt have the "," and is an archive of hundreds of codes that i need to put in sql Server 2005.

    Thank you for any help whit this.

  • Is this a one-time import or something you will be doing over and over again?

    - Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
    Property of The Thread

    "Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon

  • i need to do that over and over again.

  • This seems to work for me:

    Create View vwIngresoLector_Import

    as

    Select ImportColumn from IngresoLector

    GO

    BULK INSERT vwIngresoLector_Import FROM 'C:\Archive.dat'

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

  • thank you rbarryyoung, it works for me too

  • Glad I could help.

    [font="Times New Roman"]-- RBarryYoung[/font], [font="Times New Roman"] (302)375-0451[/font] blog: MovingSQL.com, Twitter: @RBarryYoung[font="Arial Black"]
    Proactive Performance Solutions, Inc.
    [/font]
    [font="Verdana"] "Performance is our middle name."[/font]

Viewing 6 posts - 1 through 5 (of 5 total)

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