create table dynamically

  • Hi Guys,

    I am having SP which gives, two result sets. The columns which are coming from result sets are also dynamic.

    i.e. some time 5 columns and some time 10 columns.

    Now I want to load this output into 2 different tables on daily basis. This would be truncate/delete table and load again.

    Now my problem is that as I am not sure about columns, Is it possible to create table(Physical Table) depends on output of SP, and after load data into it.

    During each load we can drop table, No issue and we can handle this through SSIS Package.

    Please suggest approach.

    Thanks,

    Abhas.

  • If the table is dropped each load then a simple select into will do the job, as long as the table name remans the same on each load

  • select * INTO tblCustomer_new FROM tblCustomer WHERE 1=2

    Will create a new table tblCustomer_new, with no rows in it

    You will have to check if table exists first and drop it.

    Check the new structure, w.r.t to fields being nullable. I know it will not create a PK on the new table.

Viewing 3 posts - 1 through 2 (of 2 total)

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