Creating a table dynamically from an existing Table Spec with required datatypes, defaults , precision and scales

  • Hi there

    I need to write some t-sql code to dynamically create columns and append to an existing table based on input columns from an existing table

    The code would have an input parameter called
    @InputString  varchar(max)  = 'TOTALCASHPAYABLE,BLU_SHARES_HELD_RECORD_DATE,BLU_SHARES_ADDCASH_ELECTION_SATISFIED'

    The code then searches an existing table for this columns and then needs to re-create their definitions and appened these to an existing table

    The complication is that it would need to take into account datatypes like Decimal , Numeric which have a Precision and Scale and
    character data types.

    So does anyone know code that is generic and can re-create columns of any datatypes along with their required attributes including defaults, precision and scales?

Viewing 0 posts

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