Data Publishing wizard for SQL Server databases

Who is online?  128 guests and 0 members
home  »  articles  »  Data Publishing wizard for SQL Server databases

Training on Microsoft Products & Technologies

Data Publishing wizard for SQL Server databases

change text size: A A A
Published: 4/10/2011 3:37:07 PM by  Amit Bansal  - Views:  [12727]

Hi Friends,

Data Publishing Wizard was one of the most popular downloads for SQL Server 2005. It allows a developer to deploy a local database from his development environment to a hosting provider on a remote system. The wizard creates a single script file which contains the schema and the data. This script file can be used to create an exact replica on the target system.

Remember, I mentioned that this wizard is available since 2007. So it was designed for SQL Server 2005 and requires SMO (SQL Management Objects) for 2005. You can still download this wizard at: http://www.microsoft.com/downloads/en/details.aspx?FamilyId=56E5B1C5-BF17-42E0-A410-371A838E570A&displaylang=en

But wait; the story is not complete; since the release of Visual Studio 2008, this wizard is integrated in to Visual Studio IDE. And yes, it means that you have this in VS 2010 as well. So, I am going to show you how you can work with this feature to publish the schema and the data in a single script file for your local database. (What I am showing you will also work with VS 2008 with minor difference in the UI)

Start Visual Studio 2010 and show Server Explorer.

Server Explorer

 

In Server Explorer, connect to the database for which you want to create the script. In my example, I am connecting to Northwind database which is located AmitBansal\sql2k8r2 instance.

Server Explorer Data Connections

 

 

Well, adding a data connection is very straight forward; just right click Data Connections and click Add Connection. Supply the necessary details including Instance name, Authentication details and the database and you are done.

Once you are connected, right click the connection you just created and click Publish to Provider…

 

 Publish to Provider

  

In the welcome wizard, click Next.

 

wlecome Database Publishing Wizard 

  

In the Select Database page, select the database which you want to script out:

 

Select Databases

 

Observe that you can script out all the objects. If you want to be selective, uncheck the option at the bottom of the page. For this example, let us uncheck this option so that we can script out only a few tables. Click Next.

In the Choose Object types pages, let us select Tables. Click Next.

Object Types

 

 

 

In the Choose Tables page, select a few a tables that you want to script out. (Be careful if you are scripting out a table with millions records :) – For this example, I am only scripting out the Orders tables. Click Next.

 

 Select Tables

In the output location, you need to specify the location of the script file. You can directly publish to the shared hosting provider by selecting a hosting provider or configuring a new one. For this example, let us script out in a file. You may overwrite an existing file. Browse and specify your file and then click Next.

Output location

 

 

In the Publishing Options page, is the real meat. You can choose to include the script for ‘drop existing objects’. You can choose to qualify every object with the schema name. You can choose the target database version which could be SQL Server 2005, 2000 or 2008 (the order is strange). Finally, you can choose to script out only the Data, or only the schema or both. Let us go ahead and choose ‘Schema and Data’. Click Next.

 Publishing Options

 

 

Review the summary and click Finish. Once done, close the wizard. Review the script file to observe it contains what you want. Do you observe that the script also contains data from some other tables like Customers and Employees. Any takes? Let us interact on this one at the forums.

 


If you liked this post, do like us on FaceBook at http://www.FaceBook.com/SQLServerGeeks

Regards
@A_Bansal
@SQLServerGeeks
www.amitbansal.net

 

 

 

 

tags : SQL Server, Database Publishing Wizard, SQL Server Database Publishing Wizard
  To rate this article please  register  or  login

Author

Amit Bansal Amit Bansal (Member since: 3/12/2011 4:59:54 PM)
Follow Amit at Twitter @A_Bansal : Amit Bansal is the CTO of eDominer Systems & Peopleware India. He is a consultant, trainer, writer, speaker & evangelist on SQL Server & Business Intelligence. A seasoned speaker; he speaks at major summits and conferences of Microsoft worldwide including TechED, MCT Summits, MSDN & TechNet conferences. Over the last 8 years, he has consulted, trained & mentored more than 6000 IT professionals on SQL Server & Business Intelligence and worked with top notch blue chip companies worldwide including Microsoft, Infosys, Wipro, RBS, HCL, HP, Siemens, IBM, Accenture, etc. He has delivered more than 400 workshops on SQL Server & Business Intelligence. Apart from holding many Microsoft credentials, he is also a Microsoft Most Valuable Professional (MVP) awardee on SQL Server. He is also one of the first Microsoft Certified Trainer in India. Amit has worked with Microsoft in India and US as a Subject Matter Expert in various capacities participating in OD sessions, technical reviewing, etc. He is also a very active community lead in Asia Pacific. Visit www.amitbansal.net to know more. Subscribe to Amit’s blog and be a member of his technical forum at www.SQLServerGeeks.com - an exclusive SQL Server portal. Visit www.peoplewareindia.com for Corporate Training solutions. FaceBook – http://www.facebook.com/people/Amit-Bansal/525339346 LinkedIn – http://www.linkedin.com/pub/amit-bansal/7/121/755

Comments (6)

sarab
4/12/2011 6:38:16 PM Sarabpreet Anand said:

Great article Amit.

The same is possible using Script Wizard of SSMS 2008.

by
admin
4/13/2011 4:21:45 PM Admin Admin said:

Hi Sarab, can you let me know which option in the script wizard allows us to publish the data?

by
sarab
4/14/2011 6:24:20 AM Sarabpreet Anand said:

Hi,

This is what i was refering to: http://www.sqlservergeeks.com/blogs/sarab/sql-server-bi/13/scripting-data-along-with-schema

Thanks,

Sarabpreet Singh

by
AmitBansal
4/20/2011 12:12:45 PM Amit Bansal said:

Hi Sarab, Those options that you showed in your blog post do not appear on my instance. I am using SQL Server 2008 R2 Dev edition. Not sure why the options are not popping up? Which version/edtiion do you use?

by
Sachin.Nandanwar
4/20/2011 12:31:51 PM Sachin Nandanwar said:

I believe the option is available in all the server editions.I checked it with the Express edition.It is available in that one to.
Are you clicking the Advanced button when the wizard comes to the Save part.Please refer to the URL for the screenshot.

http://www.picturetogo.com/images/2011/04/20/19839-script.jpg

by
sarab
4/21/2011 2:34:24 PM Sarabpreet Anand said:

Hi Amit,

I am using SQL Server 2008 R2 x86 Enterprise Edition, the one i got with MSDN subscription.

But i think this should be available over all editions (as stated by Sachin)

Thanks,
Sarabpreet Singh

by

Leave a comment

Name:
  *  
Email:  (your email is kept secure)
 *  
Website:

example: "http://www.SQLServerGeeks.com"

 
Type the characters:
 *
 
   

Training on Microsoft Products & Technologies

Training on Microsoft Products & Technologies

Email Subscriptions

   Get the Most Recent Blogs in your inbox
Articles RSS Feed

Most Recent Articles