about storing sql script in a table?

  • Hi

    Can i store the database creation script in a table call the script in stored procedure to create new database with tables and stored procedure

    can any one give me idea about this

    thanks

    with best regards

    pradeep

  • mpradeep23 (1/27/2013)


    Can i store the database creation script in a table call the script in stored procedure to create new database with tables and stored procedure

    Yes this can be done but if you rather create .sql files and then call them with the help of sqlcmd then that will be much simpler and easy to troubleshoot

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

  • mpradeep23 (1/27/2013)


    Hi

    Can i store the database creation script in a table call the script in stored procedure to create new database with tables and stored procedure

    can any one give me idea about this

    thanks

    with best regards

    pradeep

    Yes, but you will have to use dynamic SQL to actually execute scripts stored in a table as character strings. Set a variable of datatype (n)varchar with adequate scale equal to the result of the SELECT statement that returns the query you want, then run the sp_executesql system stored procedure with that variable as the input parameter value.

    Jason Wolfkill

  • Certainly. Code repository systems work on this concept.

    ----------------------------------------------------

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

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