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.
Author |
Topic |
yagorik
Starting Member
12 Posts |
Posted - 2011-06-30 : 11:59:16
|
How to script the database structure using SQLCMD, Using SMO/DMO. |
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-06-30 : 12:13:45
|
SQLCMD and SMO/DMO are mutually exclusive for accomplishing this task. It's much better and easier to use Powershell for this task:http://blogs.technet.com/b/heyscriptingguy/archive/2010/11/04/use-powershell-to-script-sql-database-objects.aspx |
|
|
yagorik
Starting Member
12 Posts |
Posted - 2011-06-30 : 12:29:29
|
I know how to use PowerShell to implement it, but you need using SQLCMD as in older versions of SQL SERVER PoSh not supported\not installed by default |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-06-30 : 12:57:30
|
You can change the Powershell script to connect to any SQL Server, not just a local one with Powershell installed. In any event sqlcmd is used to run T-SQL statements, not SMO commands. |
|
|
yagorik
Starting Member
12 Posts |
Posted - 2011-07-04 : 12:48:34
|
Used SqlPubWiz to create the database schema script. Is it possible to generate a script CREATE (create database script) for the database (similar to Script Database as-> Create To from SQL Server Management Studio) another method is desirable through the command line utilities |
|
|
robvolk
Most Valuable Yak
15732 Posts |
Posted - 2011-07-04 : 13:26:11
|
Again, I'd recommend Powershell. All SSMS scripting tasks are done using the SMO library, typically each SMO object class has a Script() method. |
|
|
|
|
|