We help IT Professionals succeed at work.

How to reverse-engineer the DDLs of all database objects with a script?

nbkd72e
nbkd72e used Ask the Experts™
on
I need a mechanism which could be executed in a script (either Windows or UNIX) to generate the DDLs of re-creating all DB objects (tables, views, stored procedures etc.) in a given SQL Server 2008 database.

Any suggestion?
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
You can do this through SQL Server.  Right-click on the database.  Select tasks, then generate scripts.

Greg

Author

Commented:
As I mentioned in the question, I need a mechanism which could be executed in a script, without human intervention.
Som TripathiDatabase Administrator
Commented:
You can use SMO to do it.
A SMO and Powershell combination can be used to accomplish it.

If you want the code, please let me know.

Author

Commented:
SMO sounds like a promising solution. Yes, code would be very helpful.
Som TripathiDatabase Administrator

Commented:
I can write code for you, but it might take time. you can read the article below and help yourself -

http://philergia.wordpress.com/2011/02/28/using-powershell-and-smo-to-script-sql-server-database-objects-3/u

Author

Commented:
Thanks folks. Now I have enough information to start with my solutions, probably powershell + SMO. It would be even better if SMO has a Java interface.