Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 82
  • Last Modified:

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

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
karthik80c
Asked:
karthik80c
  • 3
  • 2
  • 2
2 Solutions
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
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
 
karthik80cAuthor Commented:
sorry pal .I don't have the tool .can u give some query to do that and that would be great
0
 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorCommented:
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
What Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
karthik80cAuthor Commented:
oh OK thanks . let me try with the tool
0
 
Pawan KumarDatabase ExpertCommented:
Take backup of the existing database and restore it where you need.
0
 
Pawan KumarDatabase ExpertCommented:
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
 
karthik80cAuthor Commented:
Thanks and Let me do this Pal
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now