Linto
Linto

Reputation: 1272

Update query in sql server

I have two tables table1 with fields f1, f2

and

table2 with fields id,f1,f2, where id is incremental field

I need to take the values from table1 and need to insert into table2

Can anyone give the query for that,in sql server

Upvotes: 1

Views: 93

Answers (3)

mystery
mystery

Reputation: 19513

INSERT INTO table2(f1,f2) SELECT f1,f2 FROM table1

That will do exactly what you want.

Upvotes: 1

Joe Stefanelli
Joe Stefanelli

Reputation: 135789

INSERT INTO table2
    (f1, f2)
    SELECT f1, f2
        FROM table1

Upvotes: 0

Related Questions