Solved

how to automate generate scripts wizard MS SQL SEVER

Posted on 2010-08-25
4
809 Views
Last Modified: 2012-05-10
as the title suggests, I want to take a backup of all scripts that are there in the Database (not the DATA, only scripts).
Now i know that this can be done through the Generate Scripts wizard.

I want to know, how can I automate this task. e.g. create it as a JOB that runs daily.

Thanks.
0
Comment
Question by:manivineet
  • 2
4 Comments
 
LVL 31

Expert Comment

by:James Murrell
ID: 33518740
0
 

Author Comment

by:manivineet
ID: 33519171
nope. I already explored that 1
Some better ideas please.
0
 
LVL 2

Accepted Solution

by:
marat-oz earned 500 total points
ID: 33537736
In MS SQL Server 2000 you had an option to put Stored Procedure into separate file.
In SQL Server 2005 looks like you don't have this option, but you can script schema only without data itself.

Download bublishing Wizard if haven't installed it yet.
Execute the following
declare @cmd varchar(1000)
set @cmd = 'master.dbo.xp_cmdshell '
+          '''C:\"Program Files"\"Microsoft SQL Server"\90\Tools\Publishing\SqlPubWiz.exe script '
+          ' -d <database name>  -S <server name> -f -q -schemaonly <output directory>\'
+          '<database name>_'
+          convert(varchar(100), getdate(),112)
+          '.sql'''


exec (@cmd)
0
 

Author Closing Comment

by:manivineet
ID: 33680275
thnkx
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now