Search This Blog

December 29, 2008

How to generate script for data present in database

This tool works for only Microsoft SQL Server 2000 / 2005 Only.

Open the command prompt. Go to the following folder. This folder may vary based on where you installed Sql Server.

C:\Program Files\Microsoft SQL Server\90\Tools\Publishing\1.2

Type the following at the command prompt and press enter. This will take Windows Authentication. Change the databasename and file path as required.

sqlpubwiz script -d DatabaseName C:\FileName.sql

Type the following at the command prompt and press enter. 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


You can also check another free tool "SQL Scripter" at the following site.

http://www.sqlscripter.com/

No comments: