Free Newsletters:
DatabaseJournal  
DBANews
Database Journal
Search Database Journal:
 
MS SQL Oracle DB2 Access MySQL PostgreSQL PHP SQL Etc SQL Scripts & Samples Links Database Forum DBA Videos
internet.com

» Database Journal Home
» Database News
» DBA Videos
» Database Articles
» Database Tutorials
MS SQL
Oracle
MS Access
MySQL
DB2
» RESOURCES
Database Tools
SQL Scripts & Samples
Links
» Database Forum
» DBA Jobs
» Sitemap

News Via RSS Feed



follow us on Twitter

Marketplace Partners
Be a Marketplace Partner




internet.commerce
Be a Commerce Partner


















2009: The Year Microsoft 'Gets' Users?

Apple's Jobs: Condition Won't Hinder CEO Duties

LG, Netflix Plan TVs With Streaming Net Video

internet.com
IT
Developer
Internet News
Small Business
Personal Technology
International

Search internet.com
Advertise
Corporate Info
Newsletters
Tech Jobs
E-mail Offers


Database Journal | DBA Support | SQLCourse | SQLCourse2 | Swynk







Trading Systems Engineer (IL)
Next Step Systems
US-IL-Chicago

Justtechjobs.com Post A Job | Post A Resume

Featured Database Articles

MS SQL

September 1, 2004

Automating "Generate SQL Script"

By Muthusamy Anantha Kumar aka The MAK

Step 3

You can execute the above-created procedure either by passing right parameters or by using the default parameters as shown below

Exec sp__GenerateScript '',
  'D:\program files\Microsoft SQL Server\
    mssql\upgrade\',
  'D:\mssqlscripts\'

This statement will generate scripts for all of the databases on the current server and dump all of the scripts to d:\mssqlscripts\yyyymmdd folder, where yyyymmdd is today's date

or

Exec sp__GenerateScript

This statement will generate scripts for all of the databases on the current server and dump all of the scripts to d:\mssqlscripts\yyyymmdd folder, where yyyymmdd is today's date. This uses default parameters.

or

Exec sp__GenerateScript 'MSDB', 
  'D:\program files\Microsoft SQL Server\
    mssql\upgrade\',
  'D:\mssqlscripts\'

This statement will generate scripts for the database MSDB on the current server and dump all of the scripts to d:\mssqlscripts\yyyymmdd folder, where yyyymmdd is today's date.

Note

Parameter 1 is the database name. If you leave it blank, it scripts all the databases. Eg: '' or 'Master'. Default value is ''

Parameter 2 is the path information of scptxfr.exe Default value is 'C:\program files\Microsoft SQL Server\mssql\upgrade\'

Parameter 3 is the path information of the destination folder where you would like the scripts do be dumped. Default value is 'D:\MSSQLScripts\'

Parameter 4 is the various optional switches used in scptxfr.exe Default value is ' /X /Y /A /q /r /G /I '

All of the above Execute statements produce similar messages on the output widow as shown below. All the above Execute statements will create subfolders under d:\mssqlscripts, as shown in the figure FIG 1.2

Results

Generate Script - Started
Aug 27 2004 11:48PM
Information:D:\mssqlscripts\20040827 already exist. Skipping Folder Creation
"D:\program files\Microsoft SQL Server\mssql\upgrade\scptxfr.exe" /s SQL
  /d Anand /F D:\mssqlscripts\20040827 /X /Y /A /q /r /G /I
output
------------------------------------------------------------------------------
Scripting completed
NULL

"D:\program files\Microsoft SQL Server\mssql\upgrade\scptxfr.exe" /s SQL
  /d master /F D:\mssqlscripts\20040827 /X /Y /A /q /r /G /I
output
------------------------------------------------------------------------------
Scripting completed
NULL

"D:\program files\Microsoft SQL Server\mssql\upgrade\scptxfr.exe" /s SQL
  /d msdb /F D:\mssqlscripts\20040827 /X /Y /A /q /r /G /I
output
------------------------------------------------------------------------------
Scripting completed
NULL

"D:\program files\Microsoft SQL Server\mssql\upgrade\scptxfr.exe" /s SQL
  /d Northwind /F D:\mssqlscripts\20040827 /X /Y /A /q /r /G /I
output
------------------------------------------------------------------------------
Scripting completed
NULL

"D:\program files\Microsoft SQL Server\mssql\upgrade\scptxfr.exe" /s SQL
  /d pubs /F D:\mssqlscripts\20040827 /X /Y /A /q /r /G /I
output
------------------------------------------------------------------------------
Scripting completed 
NULL

"D:\program files\Microsoft SQL Server\mssql\upgrade\scptxfr.exe" /s SQL 
  /d pubs_subs /F D:\mssqlscripts\20040827 /X /Y /A /q /r /G /I 
output
------------------------------------------------------------------------------
Scripting completed 
NULL

"D:\program files\Microsoft SQL Server\mssql\upgrade\scptxfr.exe" /s SQL 
  /d Ship /F D:\mssqlscripts\20040827 /X /Y /A /q /r /G /I 
output
------------------------------------------------------------------------------
Scripting completed 
NULL

Aug 27 2004 11:50PM
Generate Script - Completed


FIG 1.2

Conclusion

This article examined how to automate the "Generate SQL Script" by using a stored procedure to take advantage of "scptxfr.exe" provided by Microsoft. Scheduling this procedure to run daily will generate one folder for every day along with all the scripts.

» See All Articles by Columnist MAK

Go to page: Prev  1  2  

Tools:
Add databasejournal.com to your favorites
Add databasejournal.com to your browser search box
IE 7 | Firefox 2.0 | Firefox 1.5.x
Receive news via our XML/RSS feed

MS SQL Archives







Latest Forum Threads
MS SQL Forum
Topic By Replies Updated
Using SQLCacheDependency in Ms-SQL 2005 prashant12se 2 January 6th, 12:06 AM
using column name as row value Osho4U 1 December 30th, 08:43 AM
merging 2 rows into 1 row taffer 1 December 30th, 07:38 AM
Help needed on Rollback transaction sukino 3 December 24th, 06:30 PM








internet.comearthweb.comDevx.commediabistro.comGraphics.com

Search:

Jupitermedia Corporation has two divisions: Jupiterimages and JupiterOnlineMedia

Jupitermedia Corporate Info

Legal Notices, Licensing, Reprints, Permissions, Privacy Policy.
Advertise | Newsletters | Tech Jobs | Shopping | E-mail Offers