Option to script Procs, Funcs, and Views

Apr 8, 2008 at 10:16 PM
I usually generate a few different SQL scripts to be checked into source control

1. Complete DDL for reverything - this script drops and creates all objects (just like the default behavior of ExportSQLScript). But this is data destructive and can't always be run against a database with data.

2. Procs-Funcs-Views Script - this script drops and re-creates all objects that can be dropped and recreated without concern of data loss. For me this is typically the stored procs, functions, and non-indexed views. This script doesn't destroy any data, so it is safe to run against a database with data.

3. SQL Scripts to recreate SQL Database diagrams - I use http://www.codeproject.com/dotnet/ScriptDiagram2005.asp to export as SQL scripts a snapshot of my database diagrams.

I think it would be great if you could include #2 as a quick command line option, like "/so:pfv" where
/so - script objects of type specfied:
p - Stored Proces
f - user defined functions
v - Views
etc. I guess you could have a flag for each intrinsic type that can be scripted including:
r - roles
s - schemas
t - tables
u - users

Then I could quickly control the scripting, like

/so:pfv - exports all procs, funcs, and views
/so:t - exports all tables
/so:ru - exports all roles and users