Monday, July 27, 2009

SQL Server: How to generate script for tables WITH data


If you have to generate script for your tables in database with data, you need to install Database Publishing Wizard for SQL Server. It is a free download from Microsoft website.

Link to Download

Localized version

After installation you need to run the following syntax in command prompt.


C:\Program Files\Microsoft SQL Server\90\Tools\Publishing>sqlpubwiz script -d YOURDB "C:\YOURDB.sql" -dataonly

The Following acknowledge will be displayed if the syntax is right...

Microsoft (R) SQL Server Database Publishing Wizard
Copyright (c) Microsoft Corporation. All rights reserved.

Generating script for database YOURDB
- Generating only data script
- Generating script targeted for SQL Server 2005
Gathering list of objects to script
Scripting objects
Writing script to disk
Writing table dbo.Members
Writing table dbo.authors

Scripting completed for database YOURDB.

Thus your Script is generated & ready for use :)

Hope it help...


1 comment:

Fauzi said...

Steps to follow while using Wizard