How do you script all object of a database to a script file 
Author Message
 How do you script all object of a database to a script file

I would like to do the following

I have a program that will have two options, Create and Save

Save is to work by
a. scripting all objects (tables,views, udf,procedures etc) of a database to
a text file
b. scripting all records in the database to a text file, if possible or will
use ado2.6
c. joining them up to a single text file for distribution. This is a project
template

Create is to work by
d. running part a of the text file (will split into 2 files)
e. running part b of the text file to populate the records

The user will decide on the name of the database and pick a template to use.
Please note that there
could be 1 - 25 or more templates.

I have become stuck on scripting the database to a text file, Could someone
please
supply an example of a sql command that will script all objects. I have
tried dmo but when I try to
run the scripts one at a time, some objects are missing, views can not be
created that contain missing objects!!

Backup and Restore is not a option since users can create databases but not
backup/restore them.

Users will not have the enterprise manager/type program

I am using MSDE 2000 and SQL 2000 Standard.

Many thanks for any advice.



Sun, 23 Nov 2003 01:58:11 GMT
 How do you script all object of a database to a script file


Quote:
> I would like to do the following

> I have a program that will have two options, Create and Save

> Save is to work by
> a. scripting all objects (tables,views, udf,procedures etc) of a database
to
> a text file
> b. scripting all records in the database to a text file, if possible or
will
> use ado2.6
> c. joining them up to a single text file for distribution. This is a
project
> template

> Create is to work by
> d. running part a of the text file (will split into 2 files)
> e. running part b of the text file to populate the records

> The user will decide on the name of the database and pick a template to
use.
> Please note that there
> could be 1 - 25 or more templates.

> I have become stuck on scripting the database to a text file, Could
someone
> please
> supply an example of a sql command that will script all objects. I have
> tried dmo but when I try to
> run the scripts one at a time, some objects are missing, views can not be
> created that contain missing objects!!

You can do this with the DMO.

You just need to also include dependant objects in your script.  This will
order the object creation in order of the dependencies.  So if view1 depends
on view2, view2 will be created first.

David



Sun, 23 Nov 2003 02:23:07 GMT
 How do you script all object of a database to a script file
David

What SQLDMOScript_????? flags would you recommend
I have been trying combinations of

'flags for the script are OR'd
'flag = SQLDMOScript_DRI_AllConstraints
'flag = SQLDMOScript_TransferDefault
'flag = flag Or SQLDMOScript_DRI_Checks
'flag = flag Or SQLDMOScript_ToFileOnly
'flag = SQLDMOScript_Default
'flag = flag Or SQLDMOScript_Indexes
'flag = flag Or SQLDMOScript_DRI_AllConstraints
'flag = flag Or SQLDMOScript_Triggers
'flag = flag Or SQLDMOScript_DRI_ForeignKeys
'flag = flag Or SQLDMOScript_UseQuotedIdentifiers
'flag = flag Or SQLDMOScript_Drops
'flag = flag Or SQLDMOScript_PrimaryObject
'flag = flag Or SQLDMOScript_IncludeIfNotExists

I will look at dmo again and this time switch on 'dependant objects '.
I will sort it this weekend;

Many Thanks; I was just about to give up DMO for this little bit of the
project and use ADO2.6 instead.

Steven


Quote:



> > I would like to do the following

> > I have a program that will have two options, Create and Save

> > Save is to work by
> > a. scripting all objects (tables,views, udf,procedures etc) of a
database
> to
> > a text file
> > b. scripting all records in the database to a text file, if possible or
> will
> > use ado2.6
> > c. joining them up to a single text file for distribution. This is a
> project
> > template

> > Create is to work by
> > d. running part a of the text file (will split into 2 files)
> > e. running part b of the text file to populate the records

> > The user will decide on the name of the database and pick a template to
> use.
> > Please note that there
> > could be 1 - 25 or more templates.

> > I have become stuck on scripting the database to a text file, Could
> someone
> > please
> > supply an example of a sql command that will script all objects. I have
> > tried dmo but when I try to
> > run the scripts one at a time, some objects are missing, views can not
be
> > created that contain missing objects!!

> You can do this with the DMO.

> You just need to also include dependant objects in your script.  This will
> order the object creation in order of the dependencies.  So if view1
depends
> on view2, view2 will be created first.

> David



Sun, 23 Nov 2003 04:52:20 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. How to Call a SQL Script file from another SQL Script File

2. any body has a script to script users permissions on db objects

3. converting paradox dos script to paradox (object pal) windows script

4. How to call file(script1.sql) from inside the script (script.sql)

5. Need Windows Scripting Host script to BCP a file using SQL-DMO

6. Find using a scripting and multiple fields - Scripts between files - Barcode plug-ins

7. AZ-Phoenix-267741--UNIX-Scripting-Relational Database-Data Warehousing-ORACLE-Unix Scripts Writer

8. Server script to run script in database (FMP Server 5)

9. File System Object Scripting... errors

10. File System object VB Script doesnt run as a job

11. Script (Database) and Batch File (Database Data) for Installation CD

12. ActiveX scripts cannot define database object...


 
Powered by phpBB® Forum Software