Monday, April 21, 2008

SQL server 2005 - generate scripts. Can i do this faster?

i am preparing scripts from DEV server, to an other environment.
step 1. script all the objects (drop script)
- 1.1. right click on tasks > select "Generate script"
- 1.2. select database click next
- 1.3. script behaviour: "Generate DROP statements only." also select
false for all the table/view options from bottom side, click Next
- 1.4. select stored procedures, user defined functions, views (this
way i won't forget any of them ... might have been modified by other
developer). click next
- 1.5. click "Select All", then Next (sps)
- 1.6. click "Select All", then Next (func)
- 1.7. click "Select All", then Next (views)
- 1.8. select script to file (any other option would be ok), change
file name to "drop scripts.sql" ? (doesn't matter) and click next
- 1.9. click finish
- 1.10 WAIT a LOT :)
then comes step 2 (2.1 - 2.10) with the only difference that at step
2.3. i'll select "Generate CREATE statements only."

i'll have 2 scripts.
in sql 2000 it was easier.

and now, the question:
can i make this somehow faster?
is there a script I could run and have the same result ...
or is there at least a way to have drop AND create-s generate all in
the same time?

I'll post an answer when i find a good one.

If you can help, just comment here pls.

Thanks

1 comment:

jezemine said...

you might want to check this out:

http://www.codeplex.com/scriptdb

it's a console app I wrote to generate scripts - you could easily modify it to do exactly what you want if you know a little C#. it's open source.