Friday, March 30, 2012
How to Script Muplitple SPROCS/VIEWS at one time
CONTROL key and then Right-Click to script out those objects.
Alternativly, pressing CONTROL-C copies, to the clipboard, the T-SQL to
create the selected objects.
SQL Management Studio seems to only allow you to script one object at a
time.
Is there a way in SQL Management Studio to select multiple objects and
generate create or modify scripts?Hi, naviagte to the database node and script the objects using the
wizard, select only the procedures you want to script.
HTH, Jens Suessmeyer.
http://www.sqlserver2005.de
--
Friday, March 23, 2012
How to run multiple script files
I have a number of script files that create various objects in my database, and to create a new DB from scratch I need to run them all in a certain sequence.
Is it possible to create a master script file that calls the others in the desired sequence?
P.S. I am using SQL Server Management Studio Express to edit and run the scripts.
There is no need to separate all your objects into separate script files, you can include them all in a single script and just separate them into Batches as appropriate. This is how we create our sample database in many cases and how most people deploy databases as part of an application.
Mike
|||Thanks for the advice, but I use a code generator and therefore need to have them in separate files.
Anyway, I worked out how to do it. First you have to click the Query menu and choose SQLCMD Mode. Then you can enter the files like this:
r: c:\myfiles\file1.sql
r: c:\myfiles\file2.sql
etc...
My path is quite long so I use a variable as follows (I also added the server connection):
:Connect MyServer\SQLExpress
:setvar SourceFolder "K:\Product Development\Programming\Current\Database\Stored Procedures"
:r $(SourceFolder)\SProc1.sql
:r $(SourceFolder)\SProc2.sql