Solved

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

Posted on 2016-09-29
7
41 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
  • 3
  • 2
  • 2
7 Comments
 
LVL 65

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 65

Assisted Solution

by:Jim Horn
Jim Horn earned 250 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

Author Comment

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

Expert Comment

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

Accepted Solution

by:
Pawan Kumar earned 250 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

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

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

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now