Results 1 to 7 of 7
  1. #1
    Join Date
    Aug 2004
    Posts
    24

    Unanswered: Output database object script to .sql file in SQL Server

    I am trying to automate the process of extracting DDL scripts for each object (Procedures, functions, Packages and not tables, views - for all schema's) on a seperate file from SQL Server database.

    For ex:
    I have about 100 procedures, 100 functions and I want to output these scripts to a .sql files on a file server at some location.

    After extraction it should be something like this:
    C:\ScriptBkp\Proc1.sql, proc2.sql, proc3.sql, so on.....proc100.sql, Func1.sql, Func2.sql, so on....Func100.sql, Pkg1.sql, Pkg2.sql, Pkg3.sql, so on....Pkg100.sql

    Proc1.sql contains the DDL for Proc1 object.

    And I want to automate this to run daily.

    How can I achieve this?

    I would really appreciate your response.

    Thanks in advance, Madhavi.

  2. #2
    Join Date
    Aug 2002
    Location
    Scotland
    Posts
    1,578
    Take help of Generate SQL scripts from Enterprise Manager --> Tools --> Generate SQL Scripts and script the objects into one file and use ISQL/OSQL to execute the script, you can also schedule this as a job using SQLAGent.
    --Satya SKJ
    Microsoft SQL Server MVP
    [IMG]http://sqlserver-qa.net/google_bart.gif[/IMG]

  3. #3
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Automate it....

    Haven't got around to this yet....

    http://www.nigelrivett.net/DMOScriptAllDatabases.html
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  4. #4
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    Automate it....

    Haven't got around to this yet....

    http://www.nigelrivett.net/DMOScriptAllDatabases.html
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  5. #5
    Join Date
    Aug 2002
    Location
    Scotland
    Posts
    1,578
    As always Brett is right on shot.
    --Satya SKJ
    Microsoft SQL Server MVP
    [IMG]http://sqlserver-qa.net/google_bart.gif[/IMG]

  6. #6
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    I don't know....see Pat's response to Surrogates?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

  7. #7
    Join Date
    Nov 2002
    Location
    Jersey
    Posts
    10,322
    You never make mention why you are doing this...any hints?
    Brett
    8-)

    It's a Great Day for America everybody!

    dbforums Yak CorralRadio 'Rita
    dbForums Member List
    I'm Good Once as I ever was

    The physical order of data in a database has no meaning.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •