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
Hello,
I m new to sql server 2005. I have an sql script. But I dont know to run it. Please help me out.
Thank U
Sir,
A)
Could you please send me the details as well, on how to automate this process.
B)
Can you answer me the professional way to create a schema of tables in sql server for database building in develpment of website in asp.net
rajesh k, you can write your own stored proc to automate this process. google for it.
Hello,
i wan to retrieve server objects relating to a user ….using c# if any one have idea do reply me …
Dear Pinal,
This is a nice article and thanks for it.
I have one question. The script generated by this only creates the empty tables & other structures. But the table data is not backed up.
Is there a way to generate this script including the data that was in the tables too? (much like a mySQL dump)?
TIA
Dear Pinal,
I just want to know
“how to get schema and data both in sql server by export”.
I have create the script for schema and get the schema but when i want to get the data it could not insert into my database. A column TimeStamp datatype is in the all the table so i have faced an error from this.
Can you please help me out.
Best Regards
Karnak
Dear Pinal,
I have one problem to solve it.
I have one server at India and another server in UK.
I need to export some data from India to UK server
But condition is we have to send only those data for which in every table selected sysid ( sysid is field in every coulmn).
there are more than
@Saurabh
Please give an example.
Hi
A question, our website was developed under sql 2005, and the server it will be installed on is sql 2008. can my website run correctly or i will face some troubles? please i need an answer urgenty?
thank you
can u please explain what is dataset,dataadapter,schema.gridview with example codes.
And also with example codes.
Hanan Salem,
There wont be much problem
Also search for Behaviour changes between SQL Server versions in Google/Bing
Views can provide advantages over tables :
———————————————————
Views can represent a subset of the data contained in a table
Views can join and simplify multiple tables into a single virtual table
Views can act as aggregated tables, where the database engine aggregates data (sum, average etc) and presents the calculated results as part of the data
Views can hide the complexity of data; transparently partitioning the actual underlying table
Views take very little space to store; the database contains only the definition of a view, not a copy of all the data it presents
Depending on the SQL engine used, views can provide extra security
Views can limit the degree of exposure of a table or tables to the outer world
i know all sp names to be apply in new db, instead of selecting the required sp in th wizard is there any possible way to run the required sp in a db.
Hello Pinal,
Thank you for this great resource! I’ve got a SQL 2005 database on a Win2000 server that I need to upgrade. I’ve created a VM with Windows 2003 server and SQL 2005.
I’d like to copy the database from the original server to the VM (which is on a different computer).
I’ve generated your script that will copy the db, schema etc. I’m wondering if you would be able to help me figure out how to move the copy to another computer/server?
Thanks in advance.
Jeff
Just run the script in another server
Thanks so much. I was looking for this.
Hello Pinal,
Data Synchronization In SQL Server database table using sql script or TSQL script or code.
I want to Synchronize my SQL Server database table at server end using client database table’s records.
Actually, I have to updated SQL Server database table data/records with the client database.
The client is sitting in the districts, who is entering the data/records collected from villages and block where there is no internate connection, so that data/records are entered offline at the client database these records must be updated and reflected at the SQL Server database at the end.
If this can be accomplish by using TSQL ,Stored Procedure.
Deepak Chandra
gr8…!
Thanks…!
deepak:
TableDiff.exe (included in SQL Management Studio) will do the job for you.
Is a prompt command that is provided with the source parameters and the destination file where the script will be generated.
Google it and you will find use esamples.
Byron.
gr8..!!
iam required to take the backup of the database on the remote server everyday at a particular time .so i do remote login daily and take backup ( right click>tasks>backup…..) and again i send the backup file back to my local system.Is there any way we can automate the entire process plz help me sir
thanks in advance
You can make use of a job and schedule it
Refer this for code sample which will take backup of database by appending current date in yyyymmdd format
Hi Pinal,
Could you please send me the details as well, on how to automate this process. I am trying to copy a database from a sql server management studio express.
Thanks so much.
Ryan