Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

about storing sql script in a table? Expand / Collapse
Author
Message
Posted Sunday, January 27, 2013 10:14 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Thursday, September 11, 2014 10:05 AM
Points: 69, Visits: 306
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
Post #1412176
Posted Monday, January 28, 2013 4:03 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 5:01 AM
Points: 2,840, Visits: 3,968
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
Post #1412322
Posted Tuesday, January 29, 2013 8:09 AM


Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Today @ 9:06 AM
Points: 1,061, Visits: 2,565
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
Blog: SQLSouth
Twitter: @SQLSouth
Post #1413068
Posted Thursday, April 11, 2013 4:38 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, September 24, 2014 4:50 PM
Points: 358, Visits: 876
Certainly. Code repository systems work on this concept.
Post #1441516
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse