Help

Help can be accessed for the Database Publishing Wizard using either of the following commands:
  • sqlpubwiz help
  • sqlpubwiz /?

Examples

From Visual Web Developer
To generate T-SQL script for your SQL Server Express database from within Visual Web Developer, perform the following steps:
  • From within Visual Web Developer, navigate to the Database Explorer. (View -> Database Explorer)
  • Select the database from within the Database Explorer that you want to publish to your shared hoster.
  • Right click on that database, then select Properties.
  • Within the Properties pane for that database, copy the Connection String to the clipboard.
  • Start the Database Publishing Wizard (Start -> Microsoft SQL Server Database Publishing Wizard -> Database Publishing Wizard)
  • Execute the following command, substituting the connection_string parameter with the value from the clipboard.

sqlpubwiz script -C "connection_string" database.sql


For example:

sqlpubwiz script -C "DataSource=.\SQLEXPRESS;AttachDbFilename=\"C:\Documents and Settings\Administrator\My Documents\Visual Studio
2005\WebSites\ClubWebSite1\App_Data\Club.mdf\";Integrated Security=True;User Instance=True;Database=ClubDB" clubdb.sql

  • Note the following things:
    • The outside quotes are required on the connection string
    • You might need to add a clause like ";Database=DatabaseName" in the connection string
    • You might have to quote the filename if there are spaces within it, as

BTW, to paste in a command window right-click on the window and select Paste.
  • The resulting output.sql file can be executed in a query window that your hoster provides.
With a normal SQL database
The following command will script the FooDB database existing on the local
machine and default instance using the Windows credentials of the executing
user to C:\FooDB.sql:

sqlpubwiz script -d FooDB C:\FooDB.sql


The following command will script the FooDB database from the default
instance on a machine named MYSERVER using SQL Server authentication with
the username "Alice" and the password "7h92-v6k3" to the file C:\FooDB.sql:

sqlpubwiz script -d FooDB -S MYSERVER -U Alice -P 7h92-v6k3 C:\FooDB.sql

Last edited Oct 25, 2006 at 2:15 AM by alexd, version 19

Comments

ahoms Jul 12, 2007 at 2:55 PM 
In the documentation file, console option "-include" appears in example B of the Script verb example section, however, this option is not refered anywhere else. Is it possible to choose which database objects to be scripted when using command line interface?

thanks

joyceschan Jul 3, 2007 at 6:39 PM 
hi, how would I go about scripting stored procedures and so forth using 'sqlpubwiz script' ?
Thanks