Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Automated script generation

Posted on 2008-06-25
4
562 Views
Last Modified: 2013-11-30
Bit of a conundrum here. SQL server management studio has a generate scripts function that allows you to script any operation that it performs, except one. It doesn't offer the ability to script the script generation function.

We run an in-house developed reporting system that downloads its static data overnight and its dynamic data from the live server on an ad-hoc basis. Due to the fact that the data is refreshed daily the data itself does not require backing up, however the database structure itself represents quite a large investment of time and resources.
I've been able to capture this structure via the script wizard but have so far been unable to automate the script generation process so that it can be backed up without the multi-gigabyte overhead of the data. I'm looking to do it through integration services if possible?
any help would be much appreciated.
CBdarchem
0
Comment
Question by:cbdarchem
  • 2
4 Comments
 
LVL 60

Accepted Solution

by:
chapmandew earned 200 total points
ID: 21904452
So, here is what you can do.  Create yourself a new SSIS package.  Throw in a Transfer SQL Server Objects task from the toolbar.  From there you can choose all of the neat objects for transfer.  What I would do is have a blank db setup specifically to accept these objects.  Transfer the objects that you want, and then backup the db that just contains those objects.  If you'd like, run profiler to see exactly how it is doing it...I am guessing that it is using SMO to go through all of the objects and script them.

FYI...there really isn't good built in functionality in 2005 for scripting objects since most of its done in SMO.  What you can do if youd like is to use the OBJECT_DEFINITION function and loop through objects and save them that way.

HTH,
Tim
0
 
LVL 15

Assisted Solution

by:jorge_toriz
jorge_toriz earned 50 total points
ID: 21922128
SELECT name, [object_id], OBJECT_DEFINITION([object_id]) AS Definition FROM sys.objects
0
 

Author Comment

by:cbdarchem
ID: 21943059
I'll have a look at these today guys - i've been off ill the past few days.
Many thanks,
Cbdarchem
0
 

Author Closing Comment

by:cbdarchem
ID: 31470498
The SSIS package was exactly what I was looking for, I ran a testbed and its spot on. The code snippet from jorge should be helpful too.
Thanks guys,
cbdarchem
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)

792 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question