March 15, 2007 at 2:31 pm
I'm sure this has to be a simple problem. I have 2 tables that are similar in every way, except that one table has a few more columns. If I wanted to select everything from the smaller table and move it into the larger table how would I go about doing that? The columns won't necessarily be in the same order.
Thanks,
-Ben
March 15, 2007 at 2:41 pm
create table bigger (
col1 int,
col2 decimal(10,2),
col3 varchar(25),
col4 datetime,
col5 int,
col6 int
)
create table smaller (
col1 int,
col2 decimal(10,2),
col3 varchar(25),
col4 datetime
)
insert into bigger (
col1,
col2,
col3,
col4)
select
col1,
col2,
col3,
col4
from
smaller
Of course, watch out for columns in bigger that may not allow nulls,
you will have to provide a default value for thoses.
March 15, 2007 at 2:52 pm
Thanks, it was easy, I just wasn't getting the syntax right. Thanks a ton!
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply