Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Script to Script DB Objects

Author  Topic 

SQLNOVICE999
Yak Posting Veteran

62 Posts

Posted - 2011-11-29 : 13:11:50
Hi Guys,

Does anyone have t-sql script to script the database with all the tables, views, constraints, indexes, triggers, UDFs, user Procs, etc? I did that using the SQL Server management studio, but I need to do it through t-sql in query analyzer...

Thanks in advance.

Laura

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-11-29 : 13:27:47
It's extremely cumbersome to do it using T-SQL. A better way is to use SMO under Powershell to generate scripts. Here's one example:

http://blogs.technet.com/b/heyscriptingguy/archive/2010/11/04/use-powershell-to-script-sql-database-objects.aspx

There are a number of Powershell DB scripting scripts out there.
Go to Top of Page

SQLNOVICE999
Yak Posting Veteran

62 Posts

Posted - 2011-11-29 : 13:29:42
Thanks a lot for the information Rob.

quote:
Originally posted by robvolk

It's extremely cumbersome to do it using T-SQL. A better way is to use SMO under Powershell to generate scripts. Here's one example:

http://blogs.technet.com/b/heyscriptingguy/archive/2010/11/04/use-powershell-to-script-sql-database-objects.aspx

There are a number of Powershell DB scripting scripts out there.

Go to Top of Page
   

- Advertisement -