?
Solved

How do i Copy All the Tables from One Database to Another in SQL Server?

Posted on 2016-09-29
7
Medium Priority
?
63 Views
Last Modified: 2016-09-29
Hi Experts,

We have created a new Database now want to move all the tables schema to the New Database , so is there any shortcut to do this on SQL Server.

Thanks in Advance
0
Comment
Question by:karthik80c
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
  • 2
7 Comments
 
LVL 66

Expert Comment

by:Jim Horn
ID: 41821965
If you have SQL Serer Data Tools (SSDT) available you can create a new database project, then do a schema compare between source db and empty target db, then execute all objects.  This will create the schema but not move any data.
0
 

Author Comment

by:karthik80c
ID: 41821972
sorry pal .I don't have the tool .can u give some query to do that and that would be great
0
 
LVL 66

Assisted Solution

by:Jim Horn
Jim Horn earned 1000 total points
ID: 41822006
There is no single T-SQL statement I know of to read schema from one database and copy it to another, other than to build a cursor with dynamic T-SQL to loop through all objects.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:karthik80c
ID: 41822010
oh OK thanks . let me try with the tool
0
 
LVL 29

Expert Comment

by:Pawan Kumar
ID: 41822108
Take backup of the existing database and restore it where you need.
0
 
LVL 29

Accepted Solution

by:
Pawan Kumar earned 1000 total points
ID: 41822114
Or Generate a DB script for Schema Only and run on the new DB.


Steps

---

  • Right Click on Your Database --> Select Task-->Generate Script..
  • Select Next in Script Wizard.
  • Select Script Entire Database.
  • Choose Your File Name. and Finish.
  • Advanced - Schema Only
  • Now you can use your script file.
1
 

Author Comment

by:karthik80c
ID: 41822883
Thanks and Let me do this Pal
0

Featured Post

What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question