Subscribe For Free Updates!

We'll not spam mate! We promise.

Aug 16, 2012

Generate Data Base Script in Sql Server

Views:

Generate Data Base Script in Sql Server
 Today I will show you how to Generate Full Data Base Script in SQL Server 2008 or 2005.
By Generating SQL Data Base script basically we copy complete database schema and all of its objects such as Stored Procedures, Functions, Triggers, Tables, Views, Constraints etc. You can review your schema, backup for reference or use it to compare with previous backup.
SQL Server Management Studio provides an efficient  wizard to generate scripts to transfer objects along with their dependencies as well as the data.
In this tutorial, let's firstly generate a migration script for the following objects from the AdventureWorks database:





Script objects Includes Tables,Store Procedures,Views and User Defined Functions.
One of our requirements is to move the objects along with their related keys, constraints, relations, triggers, user defined data types, etc. To generate a script for the migration process let's right click on the your Required database, select the 'Tasks' and 'Generate Scripts' options as shown below:
Generate Data Base Script in Sql Server
The wizard is the welcome screen as shown below.  Click the Next button to continue the process.

Generate Data Base Script in Sql Server






















The second screen of wizard is the 'Select Database' screen.  On this screen we need to select the appropriate database.We are also not going to select the 'Script all objects in the selected database' option since we only want to migrate a subset of the objects.  Next click the 'Next' button to continue the wizard.

Generate Data Base Script in Sql Server





















In this  'Choose Script Options' screen and Press Next Button.( NOTE:-Select these options very carefully because all these options will be reflected in the generated script for the migration process.)

Generate Data Base Script in Sql Server




































Here Checked Required Object and , click the 'Next' button.

Generate Data Base Script in Sql Server





















Select your Required Store Procedures and Then Next.


Generate Data Base Script in Sql Server





















Select your Required Tables and Then Next.

Generate Data Base Script in Sql Server





















Select your Required Views and Then Next.

Generate Data Base Script in Sql Server






















Select your Required User Define Functions and Then Next.

Generate Data Base Script in Sql Server
























In the 'Output Option' screen is intended to determine the final output for the wizard.  The options include generating a file in a specified path, copying the contents to the clipboard or saving the results to a SSMS query window.  In our example, I have choose to script in a new query window.

Generate Data Base Script in Sql Server





















Next will be the 'Script Wizard Summary'  screen which summarizes all of the options selected in the wizard.  Click the 'Finish' button to begin the script generation.

Generate Data Base Script in Sql Server






















Once you press the 'Finish' button the 'Generate Script Progress' screen will outline the status of each step.

Generate Data Base Script in Sql Server






















Below is a sample screen shot of the script generated .  You can also review the generate script here.

Generate Data Base Script in Sql Server

Plese Feel Free to Socializer This Post
SOCIALIZE IT →
FOLLOW US →
SHARE IT →

0 comments:

Post a Comment

Become a Fan

visual studio learn