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
Hi Pinal,
Would you please send me the details as well, on how to automate this process.
Thanks,
Christine
Hi Dave,
I would like to have that details also.
thanks in advance.
Merry X’mas,
Jule
thank you
Hi Dave;
Would you please post or provide your method for automatically scripting databases for SQL Server 2008?
Thaks!
I would like to see your automation technique for script generation.
Thanks,
Dave
Hi Pinal,
can you share with us how to automate the creation of existing SQL2005 Scheduled Jobs into T-SQL script for disaster recovery purposes please?
Thanks.
For those of you asking Pinal to show you how to preform automation, please see the CodePlex site. [ ]
Read the Database Publishing Wizard documentation.
There are multiple command line switches you can use:
Command Line Syntax
sqlpubwiz script
(
-C connection_string | -d local_database_name
[ -U local_user_name ][ -P local_password ][ -S local_server_name ]
)output_file_or_directory [ -f ]
)
[ -schemaonly ]
[ -dataonly ]
[ -targetserver server-version ]
[ -noschemaqualify ]
[ -nodropexisting ]
[ -q ]
[ -? ]
sqlpubwiz publish
(
-C connection_string | -d local_database_name
[ -U local_user_name ][ -P local_password ][ -S local_server_name ]
)
(
[ -R hoster_name ]
[ -RW remote_web_service_addr ]
[ -RWU remote_service_user_name ]
[ -RWP remote_service_password ]
[ -RS remote_databse_server ]
[ -RD remote_database ]
)
[ -schemaonly ]
[ -dataonly ]
[ -targetserver server-version ]
[ -noschemaqualify ]
[ -nodropexisting ]
[ -notransaction ]
[ -q ]
Thanks :-)
Scott Gleason
i am just staring to work with sql 2005 server,i have to create
sql statement for display telphone number that mean there is
database for all telephone number but when people call us i have to
split taht phone number like country code ,localID,PBX,Exten for example
let say one number 0443965045 in this number 0 for country code,
44 for localID,39650 for PBX the rest 45 for EXTEN,could you
please help to wrtie sql for this condition and also when i get
extension number with one digit like 1 or 2 or 3 this must be disply with 0
that mean like 01 or 02 or 03
could you please
how to get speedly data form remote sql server in vb.net
how to get speedly data form remote sql server in vb.net desktop application
Hi,
i am just staring to work with sql 2005 server, for our software jobboss as backend support, where should i get the data stored in the database. how could i modify or change the data in it. please help me, thanx in advance.
Dear sir
Please Send this mail to me also.
HI Pinal Dave,
CUD U PLZ HELP ME ..
I WANT TO migrate all tables from mysql to sql server. (Import all schemas to SQL server without data)..
BUT HOW PLZ TELL ME ..
REGARDS,
HIMANSHU
You need to generate script in Mysql;change the datatypes compatible to SQL Server and run it in SQL Server
Manikandan,
Hai Pinal..
I need a solution for how to generate a script tables structure with records
Thank you
If you use versions starting from 2008, there is an option. Otherwsie you need to use bcp to export data
What is the best way to script schema difference and automate the execution of the script .
for e.g. you want to release next version of your application and some modifications to the database schema. I have a copy of the old version db which I want to compare it to the new one and generate the script for the difference.
Thanks
Rakesh
imagine i have a database “X” and database “Y”
database X has tables “X1” “X2” “X3” “X4”
database Y has tables “Y1” “Y2” “Y3” “Y4”
i have to update table X1 with the values of Y1.
i dont need too specific like x and y. i need a common query for doing the above mentioned method.
Why dont you make use of import/export wizard from SSMS?
I wanna wirte automatic script … so can yo explain me and give query… This script want for one month to one month
Could you please e-mail the automation script as well?
Thanks so much.
How can create a password on my existing database in sql server 2005
hi
i am using local database to my application . i want to upload daily transactions into remote database (not for total database )
could you please tell me how to generate script of one day transactions in sqlserver 2005 and and integrate with database remote server
Sir I Want To Copy Stored Procedure From One Database To Other Database In Same SQL Server 2005
Please Help Me
Generate script and run it in other database
Good Day Pinal Dave,
Can you advice on the script for mirroring the database from MSSQL2008 as live database to MSSQL2005 as backup database?
Thanks,
William