Friday, March 9, 2012

script database - create to file

In the management studio there is a function to dump the DDL of a database, script database create to and then I can choose file.

What I was wondering and can't seem to find is, whether it is possible to somehow call this function from a program.

Any language, and connection will do for now, if at all posible, or if there is some other way I haven't found to dump the DDL for a database this woudl be much appreciated.

btw, I'm using a mssql 2005 database.

Regards

Unfortunately, that isn't possible. But here are several ways to approach the issue.

DDL -Script Database to File
http://www.wardyit.com/blog/blog/archive/2006/07/21/133.aspx
http://www.sqlteam.com/publish/scriptio
http://www.aspfaq.com/etiquette.asp?id=5006
http://www.codeproject.com/dotnet/ScriptDatabase.asp
http://www.nigelrivett.net/DMO/DMOScriptAllDatabases.html
http://rac4sql.net/qalite_main.asp

DDL –Script Data to file (Database Publishing Wizard)
http://www.microsoft.com/downloads/details.aspx?FamilyID=29B4FFD8-AC3A-4481-B352-9B185619A901

|||

Hi,

Just to add a thought here - you could use SMO to achieve the task. For instance, SMO exposes a Database object with a Script() method. It is very well documented in the SQL Books Online.

In addition, you could take an easy shortcut - you could use SSIS (the new DTS) and create a scripting task. Then you could simply kick-off the task from your application.

HTH,
Jivko Dobrev - MSFT
--
This posting is provided "AS IS" with no warranties, and confers no rights.

No comments:

Post a Comment