Have txt/csv files, but header need to find from which row it will start

  • Jeff Moden

    SSC Guru

    Points: 996676

    Almost done with setting up some substantial test data for this thread but I need some more information.

    1. Will the embedded header (the line with ID,name,sal on it) ALWAYS be immediately preceded by a NULL or blank line?
    2. Will Colons (:) EVER be allowed as a delimiter for the actual data rows?
    3. Also, which revision of SQL Server are you using?  2016? 2017?  or  ???

    Ah... I also just noticed which forum this is posted to, so also be advised that I don't use SSIS for these types of things (heh... one of my specialties is making SSIS unnecessary for these types of things 😀 ).  My solution will be a T-SQL solution.  If that doesn't work for you, then someone else will need to help.

    Please let me know so I don't waste either of our times.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".
    "If "pre-optimization" is the root of all evil, then what does the resulting no optimization lead to?"

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • DBA.k

    Ten Centuries

    Points: 1085

    Hello jeff thank you so much for yours help..

    1.I am happy even TSql .. as per given DDL statement in my post data will be there in table.. just find the header which is there in 3rd may be that will change also column names will be different.. so need to find the header row from table and that row should make table create schema... That's fine for me in TSql  I am using Sql server 2014...

    • This reply was modified 2 months, 1 week ago by  DBA.k.
    • This reply was modified 2 months, 1 week ago by  DBA.k.
  • Jeff Moden

    SSC Guru

    Points: 996676

    Excellent.  I'll get back to it later tonight then.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.
    "Change is inevitable... change for the better is not".
    "If "pre-optimization" is the root of all evil, then what does the resulting no optimization lead to?"

    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • DBA.k

    Ten Centuries

    Points: 1085

    Thanks Jeff .. please help if you have time..

Viewing 4 posts - 16 through 19 (of 19 total)

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