Need Help with Scripting

  • Hi everyone,

    I am looking for some help as I suck at scripting..

    I have a text file in which the data starts from the fifth row. I am able to upload that part easily.

    However the first four lines contains four dates which needs to be extracted into a separate table.

    Any help would be great.

    Regards

  • Is this a one time load, or a reoccuring task? Is the date embedded within the first four lines, or are they complete lines. Could you post some sample data?

    You haven't given much for anyone to help you on.

  • 2011-09-09 00:00:00GMT

    2011-09-10 00:00:00GMT

    2011-09-10 00:30:00GMT

    2011-09-10 00:30:01GMT

    NTC-A;NTC-B;HDC-A;HDC-B;

    AAP;260;260;260;260;

    And so on....

    The dates are complete lines. Not embedded within any lines......

    This is a recurring task (Daily task infact).

  • The OpenRowset function (details here: http://msdn.microsoft.com/en-us/library/ms190312.aspx) allows you to assign first and last rows for imports using it.

    Will it always be four dates in every file, or does it vary?

    - 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

  • Yes. It will be four dates..

    I do not want the data from the fifth line and only these four dates into a table.

    Is it possible with openrowset. Can you provide an example please...

  • SELECT *

    FROM OPENROWSET(BULK 'MyFilePathAndName', FORMATFILE='MyFormatFile', LASTROW=4) AS MyFileImport ;

    That's a sample. You'll need an actual file and an actual format file. There are samples of format files that you can get from the link I posted.

    This sample will select the first 4 rows of data.

    - 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

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

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