Script job to create scripts 
Author Message
 Script job to create scripts
Is there a way that I can create a script that I can schedule that will
automatically generate schema, replication, and job scripts so that I can
back them up?


Sat, 18 Jan 2003 03:00:00 GMT
 Script job to create scripts

No, but you can easy write a VBScript using SQL-DMO which does this like
this:

    Dim oSQLServer ' As SQLDMO.SQLServer
    Dim oDatabase ' As SQLDMO.Database
    Dim oTable ' As SQLDMO.Table

    Dim iOptions1
    Dim iOptions2

    iOptions1 = -2147086012 ' SQLDMOScript_Default +
SQLDMOScript_AppendToFile + SQLDMOScript_UseQuotedIdentifiers +
SQLDMOScript_OwnerQualify + SQLDMOScript_IncludeHeaders +
SQLDMOScript_IncludeIfNotExists + SQLDMOScript_ToFileOnly
    iOptions2 = 2 ' SQLDMOScript2_Default + SQLDMOScript2_AnsiFile

    Set oSQLServer = CreateObject("SQLDMO.SQLServer")

    oSQLServer.LoginSecure = True
    oSQLServer.Connect "(local)"

    For Each oDatabase In oSQLServer.Databases
        For Each oTable In oDatabase.Tables
            If Not oTable.SystemObject Then
                oTable.Script iOptions1, "d:\script.sql", , iOptions2
            End If
        Next
    Next

    oSQLServer.DisConnect
    Set oSQLServer = Nothing

You would have to add triggers, indexes etc, but it is the same principle.



Sat, 18 Jan 2003 03:00:00 GMT
 Script job to create scripts

You will have to code this yourself using the WMI or DMO API's - check books
online for these topics.

--
Tony Rogerson SQL Server MVP.
Torver Computer Consultants Ltd
www.sql-server.co.uk

Office:        +44(0) 1582 768450
VM/Fax:    +44(0) 870 168 2150
Mobile:       +44(0) 796 816 0362


Quote:
> Is there a way that I can create a script that I can schedule that will
> automatically generate schema, replication, and job scripts so that I can
> back them up?



Sun, 19 Jan 2003 03:00:00 GMT
 
 [ 3 post ] 

 Relevant Pages 

1. Script size problem when executing an Active Script job

2. SQL-DMO (Active script within job step) Problems with Script statement

3. Generate scripts creates an error in script

4. How do I create a script that runs other scripts

5. Creating a job to do database script

6. Creating a job to script the database

7. Creating Job Step w/ ActiveX Script (VBScript)

8. Creating Job (or scheduling of SQL scripts)

9. How to create a Job to Script Replication ?

10. Creating a job tto automate generating of scripts.

11. creating SP from create table script

12. Creating SQL script to create database WITH data


 
Powered by phpBB® Forum Software