Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Copy columns from one table and database to another table and database

Posted on 2014-12-02
2
Medium Priority
?
361 Views
Last Modified: 2014-12-02
Hello

Is there any  short way to copy  a table with no data (just columns) from one database to another table from another database using MSSQL 2008?

I tried doing design table, and than on Edit, i selected copy the columns but when I go to add a new table on another database and paste the columns, it does pasta all row fields in one row. Is there anything I am doing wrong.

thank you
0
Comment
Question by:shpresa
[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
2 Comments
 
LVL 10

Expert Comment

by:Walter Padrón
ID: 40477426
Open SSMS and right-click over the desired table, then Script table as .. / DROP and CREATE To / Clipboard
and you have a script that recreate the table.

Best regards
0
 
LVL 18

Accepted Solution

by:
Simon earned 2000 total points
ID: 40477429
Use SSMS.
1.Right click the source table and choose script /create to new query window
2.Go to the top of the query window and insert the following line (or select the desired database in the combobox)
Use destinationdatabase
3. Execute the script

Or a really basic way...
use sourcedb
select *
into destinationdatabase.schemaname.tablename
from sourcetable
where 1=2
0

Featured Post

Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
Recently I was talking with Tim Sharp, one of my colleagues from our Technical Account Manager team about MongoDB’s scalability. While doing some quick training with some of the Percona team, Tim brought something to my attention...
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…

715 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