Scripting a database using Transact-SQL

  • Hi,

    In Enterprise Manager you can right-click on a database then from the All Tasks you can select the Generate SQL Script option.

    I would like to do this manually using Transact-SQL so that this task could be scheduled as a job to be run periodically.

    Can anyone help please.

     

  • At another job I did this using VB and SQL-DMO.  DMO contains objects and methods that can generate scripts.  Check it out in the books online.  I looped thru all of my databases and servers to create backup scripts of all my databases.

    It was a few years ago, so I'm not sure what objects I used, I think it was the BULKCOPY object...

    Steve

  • see

    http://www.nigelrivett.net/DMOScriptAllDatabases.html

     


    Cursors never.
    DTS - only when needed and never to control.

  • Use scptxfr.exe utility located in \MSSQL\Upgrade\ folder and schedule CmdExec step.

       scptxfr.exe /s server1 /d pubs /I /f c:\pubs.sql /A

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply