Update: This article is re-written with SQL Server 2008 R2 instance over here: SQL SERVER – 2008 – 2008 R2 – Create Script to Copy Database Schema and All The Objects – Data, Schema, Stored Procedure, Functions, Triggers, Tables, Views, Constraints and All Other Database Objects
Following quick tutorial demonstrates how to create T-SQL script to copy complete database schema and all of its objects such as Stored Procedure, Functions, Triggers, Tables, Views, Constraints etc. You can review your schema, backup for reference or use it to compare with previous backup.
Step 1 : Start

Step 2 : Welcome Screen

Step 3 : Select One or Multiple Database
If Script all objects in the selected database checkbox is not selected it will give options to selected individual objects on respective screen. (e.g. Stored Procedure, Triggers and all other object will have their own screen where they can be selected)

Step 4 : Select database options

Step 5 : Select output option

Step 6 : Review Summary

Step 7 : Observe script generation process

Step 8 : Database object script generation completed in new query window

Reference : Pinal Dave (https://blog.sqlauthority.com), All images are protected by copyright owner SQLAuthority.com





673 Comments. Leave new
I want to database with data so i am generate Script but In sql server my ansi padding Option is not available . and only genarete script which is contain table but not data. so how can i get table with data?
If you want data too, it is better to take a backup
Hi,
I have two databases : Local , Prod
Made the table structure changes into the Local DB tables.
now i want to apply the changes on the production server while preserving data on the production server.
thanks in adv..
Vikas
Take alter table scripts and run them in the production server
Before that make sure you have a very recent backup of the production database
Hi Pinal,
I hav 2 DB’s names TESTDB and SAMPLEDB , both DB table name is same(tableinsert) and fields name also same.
I got TESTDB backup. Now i want to know whenever i restore .bak file to TESTDB at the same time SAMPLEDB also changed if it’s possible..? pls send me code and ideas..
Thanks In advance
No they wont be changed automatically until you restore both the databases
Thanks you.
Excuse my bad english.
Error on replicated table.
When i run sqlpubwiz on database with replicated table, i have : Erreurÿ: Erreur de syntaxe dans TextHeader de NumberedStoredProcedure ®ÿsp_MSdel_dboORD_PRO_PreneursOrdres;2ÿ¯.
thank you thank you thank you I have been pulling my hair out trying to get ms publishing wiz to work but every where I looked I was told to do this longgggggg and complicatedddddd procedure i.e. you got this error because your db engine isn’t on (how do I turn it on? no answer) I was stuck looking and looking reading and reading. I will be the first to admit I still have a long way to go with c#.net, vwd and sql server before I will qualify as a web master but you have helped me immensely toward my goal of getting online and for this I can not thank you enough
Hello Sir,
i want to configure SQL SERVER 2008. when i give permission on perticular database with particular User id as DBO. that user access only that particular database.but he can see all Databases in his SMO.
how can set , only the pemissable database see in his SMO. not all database on Server.
thanks in Advance
give me Reply as soon as possible.
Hello sir
How to import the MS access database into SQL server 2005.
i want the code in vb.net .
Read about OPENDATASOURSE in SQL Server help file
Im developing a website.. & at d last i hv came to knw that d database must be on SQL server.. how could i create script, and reuse my old DB. i cant create d DB twice.. its too large.. plzzz smbody reply……………………………plzzzzzzzzzzzzzzzzzzz
If you have old db you can use it. What is the problem are you facing?
I want to know about using SQL 2005 in bassic please
Please help me
I want to know about using SQL Server 2005 in bassic
Thanks — great blog
I am using VB.NET 2005 and SQL Express 2005. When I run the application it able to insert new records, but when I close the application the data is not reflecting in database.
Please help.
hi ,
i want to generate automated backup from the database in sql server 2005 & 2008, so is it possible? if yes then how and please tell me what is the procedure for that. i m waiting for your reply..
thanks,
Hi Ankit
-After Login,Expand Management->create new Maintenance plan
-Drag ‘Back Up Database Task’ to design window
-Then right click and edit the back up database task as per your requirements
-Finally make a schedule and save it.
Hope,you were looking for this sol!!!
Amit
Hi
I want to copy a databse with table’s content,constraint(everything) to local machine without any wizard.
Is there any SP or any other way,where i can copy one database and paste the same database with different name through script.
Thanks
Amit
You can make use of backup
Backup database your_db to disk=’File_path’
You can restore it in different name using
Backup database your_new_db to disk=’File_path’
Thankx for the reply
But i cant take backup and restore as the path would be different always.
Also it would be time consuming too as mine is a huge database.
If you know any other way,please let me know
Thanks
Amit
Read about SMO in SQL Server help file
hi
thanks a lot this site helped me a lot bzc i was doing the work in the office but i am unable to co
I want to know that how we create a script with the backup of data that is store in the tables from server’, database????????
Write this query
backup database db_name to disk=’file_path’
Thanks Alot. It help’s me.
—
VenkataRavi.CR
Hi, pls help me. I need to write a query to find where data is storing by default after taking a backup in SQL.. I need to run dis query in many systems.. pls help me…
It is stored at the location that you speficify at the query
backup database db_name to disk='file_path'
can we generate a script for blank database in SQL Server 2008.
If you dont have any objects, obviously you wont get anyting in the script