create db dynamically

  • Checking if anyone has experience doing this...

    I have a datawarehouse (star schema)... one of the dimensions is company... based on the company, I have to create database with relevant data dynamically... basically need a Proc that will be parmaterized which creates database with data related to only that particular company....

    Any suggestion is appreciated. Thanks!

  • Is there a way through sql proc to script the table and db from original database and use that dynamically to create a database for the company using the new name? Once created, I can insert relevant records in the tables...

  • I suppose you could just create a dynamic sql statement to create the database with the company name as a variable, and execute that.

  • yes that we can do and I guess we can create the tables with relevant data also using the dynamic sql.... I have planned to do this, but was checking if we can get the script to create db and table and use that.. or at least I can script the constraints and keys. Thanks for the response.

  • Ghanta (9/15/2010)


    Is there a way through sql proc to script the table and db from original database and use that dynamically to create a database for the company using the new name? Once created, I can insert relevant records in the tables...

    Could you just script a backup and restore dynamically?

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

  • Thanks Jeff I will check that option.

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

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