Solved

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

Posted on 2014-12-02
2
338 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
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 500 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
the whoisactive update 12 39
Exchange 2010 - Best practice MDB Data size 8 58
Help Parsing a String with SQL Syntax 23 32
constraint check 2 19
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

861 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