I want to find header row dynamically and create table schema with that header.

  • CREATE TABLE [dbo].[NewTable1](

    [18/10/2020 date] [nvarchar](255) NULL

    ) ON [PRIMARY]

    GO

    INSERT [dbo].[NewTable1] ([18/10/2020 date]) VALUES (N'This is test file')

    INSERT [dbo].[NewTable1] ([18/10/2020 date]) VALUES (NULL)

    INSERT [dbo].[NewTable1] ([18/10/2020 date]) VALUES (N'20-20-2020')

    INSERT [dbo].[NewTable1] ([18/10/2020 date]) VALUES (NULL)

    INSERT [dbo].[NewTable1] ([18/10/2020 date]) VALUES (N'ID,name,sal')

    INSERT [dbo].[NewTable1] ([18/10/2020 date]) VALUES (N'10,mahi,2000')

    INSERT [dbo].[NewTable1] ([18/10/2020 date]) VALUES (N'20,ravi,1000')

    INSERT [dbo].[NewTable1] ([18/10/2020 date]) VALUES (N'30,ram,3000')

    INSERT [dbo].[NewTable1] ([18/10/2020 date]) VALUES (N'total emp:3')

    As per above script data will store in a single column with cama separate or any other delimiter which is semicolon ; etc.. so first i need to find out in which row header will be there and based on header (ID,name,sal') i need to create table schema dynamically.. so may be in another table i have more columns that has to automatically create table with that header..

    Kindly help on this ....

     

    • This topic was modified 3 years, 11 months ago by  DBA.k.
    • This topic was modified 3 years, 11 months ago by  DBA.k.
  • Why have you started a new thread about this?

    Original thread here includes as-yet unanswered questions for the OP.

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Thank you.. I am sorry But that unanswered question is regarding SSIS process from txt file.. This having next task which is data will be in Sql server table.. From that need to find header and create table.. I am sorry now  i have unsubscribe the old one..

    • This reply was modified 3 years, 11 months ago by  DBA.k.
  • can you please help on this task

  • DBA.k wrote:

    can you please help on this task

    Yes but let's stop this thread and take it back to the original thread where I see you've provided the information I asked for.  I can't help right this instant because I'm working but will have a go of it tonight.

     

    --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.


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

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

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