16

Im using SQL Server 2005.

I have a table1 with 3 columns. And table2 with 4 columns.

I want to insert the records from table1 into table2.

But I dont want to insert into column1 from table2.

I want to start inserting from column2 on.

What can i do? Thanks...

pyram
  • 925
  • 9
  • 24
  • 43

5 Answers5

33
insert into table2
(
    col2, col3, col4
)
select col1, col2, col3
from table1
5

You can combine select and insert in order to do this. This is how:

insert into table2 (col2, col3, col4)
select col1, col2, col3
from table1
bnvdarklord
  • 309
  • 2
  • 6
2

You will just need to use a SELECT...FROM in your INSERT to select the columns you want.

INSERT INTO table2
(
    column2, column3, column4
)
SELECT column1, column2, column3
FROM table1
Taryn
  • 242,637
  • 56
  • 362
  • 405
1
INSERT INTO Table2 (column2,colum3,column4 )
SELECT  column1,column2,column3 FROM    Table1
Shyju
  • 214,206
  • 104
  • 411
  • 497
1
into into table2
(column2,......)
select column2 ..... from table1