?
Solved

Easiest way to insert new data to table with large number of columns

Posted on 2014-08-29
6
Medium Priority
?
165 Views
Last Modified: 2014-08-30
Experts,

In SQL Server 2014, I have new data sitting in a table (second table) that I need to append to another table (the first table).
Both tables schemas are identical and have 60 columns each.
I'm lazy and really don't want to write an INSERT INTO query referring to all 60 columns individually.
Is there an easier way?

Thanks in advance.
0
Comment
Question by:bobinorlando
6 Comments
 
LVL 75

Expert Comment

by:Aneesh Retnakaran
ID: 40293588
You can generate the insert script from SSMS,
0
 
LVL 75

Accepted Solution

by:
Aneesh Retnakaran earned 1000 total points
ID: 40293592
right lick the database -> generate scripts -> choose the table - > next -> advanced options- >  there should be a property that says script data
0
 
LVL 66

Assisted Solution

by:Jim Horn
Jim Horn earned 1000 total points
ID: 40293607
>Both tables schemas are identical and have 60 columns each.
As long as the table schema is the same...

INSERT INTO new_table SELECT * FROM old_table
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!

 
LVL 1

Expert Comment

by:jsaun
ID: 40293840
or even:  CREATE TABLE NEW_TABLE_NAME AS (SELECT * FROM OLD_TABLE_NAME);
0
 
LVL 66

Expert Comment

by:Jim Horn
ID: 40294514
Thanks for the grade.  Ironically this question was on the 70-461 exam as 'What is the easiest way...', regardless of whether it is a best practice or not.  Tricky.
0
 
LVL 1

Author Comment

by:bobinorlando
ID: 40294941
Wow I didn't realize
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
Using examples as well as descriptions, and references to Books Online, show the documentation available for date manipulation functions and by using a select few of these functions, show how date based data can be manipulated with these functions.
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.
Suggested Courses

850 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