Load Text file data to structured table format

  • Hi Team,

    I'm trying to load history of TFS script deployed to database.

    The output of history is as below, how can I get this on SQL in table format.

    Thanks in advance

    Need Output Table

    Changeset: 1234User: XXXXDate: Monday, April 15, 2016 1:36:11 PMBranched from $/Project1/Prodbranch $/Project1/Product/Databases/DB/View/view1.sql
    Changeset: 2345User: XXXXDate: Monday, April 15, 2016 1:36:11 PMBranched from $/Project1/Prodbranch $/Project1/Product/Databases/DB3/Table/Table2.sql

    TFS history file:

    -----------------------------------------------------------------------------------------------------------------------
    Changeset: 1234
    User: XXXX
    Date: Monday, April 15, 2016 1:36:11 PM

    Comment:
    Branched from $/Project1/Prod

    Items:
    branch $/Project1/Product/Databases/DB/Views/view1.sql

    -----------------------------------------------------------------------------------------------------------------------
    Changeset: 1234
    User: XXXX
    Date: Monday, April 15, 2016 1:36:11 PM

    Comment:
    Branched from $/Project1/Prod

    Items:
    branch $/Project1/Product/Databases/DB3/Tables/Table2.sql

  • Is that output table a single column...? I'd suggest it would be better to have each item as a column. Why do you want to convert it into Delimited Tab format on your SQL Server where each item hasit's header prior to it? That's going to be awful to query.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Tsql-561486 - Thursday, November 30, 2017 8:00 AM

    Hi Team,

    I'm trying to load history of TFS script deployed to database.

    The output of history is as below, how can I get this on SQL in table format.

    Thanks in advance

    Need Output Table

    Changeset: 1234User: XXXXDate: Monday, April 15, 2016 1:36:11 PMBranched from $/Project1/Prodbranch $/Project1/Product/Databases/DB/View/view1.sql
    Changeset: 2345User: XXXXDate: Monday, April 15, 2016 1:36:11 PMBranched from $/Project1/Prodbranch $/Project1/Product/Databases/DB3/Table/Table2.sql

    TFS history file:

    -----------------------------------------------------------------------------------------------------------------------
    Changeset: 1234
    User: XXXX
    Date: Monday, April 15, 2016 1:36:11 PM

    Comment:
    Branched from $/Project1/Prod

    Items:
    branch $/Project1/Product/Databases/DB/Views/view1.sql

    -----------------------------------------------------------------------------------------------------------------------
    Changeset: 1234
    User: XXXX
    Date: Monday, April 15, 2016 1:36:11 PM

    Comment:
    Branched from $/Project1/Prod

    Items:
    branch $/Project1/Product/Databases/DB3/Tables/Table2.sql

    Two options come to mind
    1) Write a chunk of code in an asynchronous script component 
    2) Import every row of data as a single string to a staging table, adding a row number to allow you to preserve ordering. Then write a ghastly stored proc which extracts the data from the staging table in the desired format.
    Either way, this is going to require some significant coding.

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Thom A - Thursday, November 30, 2017 8:07 AM

    Is that output table a single column...? I'd suggest it would be better to have each item as a column. Why do you want to convert it into Delimited Tab format on your SQL Server where each item hasit's header prior to it? That's going to be awful to query.

    Yes, the initial output file is loaded to a table with single column, I'm looking to have this in table format from that single column table.
    Each item as column may not be an option, as in production the number of script history might be more....

  • ChangesetUserDateBranchedFrombranch
    1234 XXXXMonday, April 15, 2016 1:36:11 PM$/Project1/Prod $/Project1/Product/Databases/DB/View/view1.sql
    2345 XXXX Monday, April 15, 2016 1:36:11 PM$/Project1/Prod $/Project1/Product/Databases/DB3/Table/Table2.sql

  • Phil Parkin - Thursday, November 30, 2017 8:08 AM

    Tsql-561486 - Thursday, November 30, 2017 8:00 AM

    Hi Team,

    I'm trying to load history of TFS script deployed to database.

    The output of history is as below, how can I get this on SQL in table format.

    Thanks in advance

    Need Output Table

    Changeset: 1234User: XXXXDate: Monday, April 15, 2016 1:36:11 PMBranched from $/Project1/Prodbranch $/Project1/Product/Databases/DB/View/view1.sql
    Changeset: 2345User: XXXXDate: Monday, April 15, 2016 1:36:11 PMBranched from $/Project1/Prodbranch $/Project1/Product/Databases/DB3/Table/Table2.sql

    TFS history file:

    -----------------------------------------------------------------------------------------------------------------------
    Changeset: 1234
    User: XXXX
    Date: Monday, April 15, 2016 1:36:11 PM

    Comment:
    Branched from $/Project1/Prod

    Items:
    branch $/Project1/Product/Databases/DB/Views/view1.sql

    -----------------------------------------------------------------------------------------------------------------------
    Changeset: 1234
    User: XXXX
    Date: Monday, April 15, 2016 1:36:11 PM

    Comment:
    Branched from $/Project1/Prod

    Items:
    branch $/Project1/Product/Databases/DB3/Tables/Table2.sql

    Two options come to mind
    1) Write a chunk of code in an asynchronous script component 
    2) Import every row of data as a single string to a staging table, adding a row number to allow you to preserve ordering. Then write a ghastly stored proc which extracts the data from the staging table in the desired format.
    Either way, this is going to require some significant coding.

    Thank you Phil, got it worked with Option 2.

  • Tsql-561486 - Friday, December 1, 2017 1:07 PM

    Thank you Phil, got it worked with Option 2.

    Well done! Out of interest, how many rows of code were required?

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

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

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