Friday, March 7, 2008

Power of SQL: Insert from Select

Continuing the discussion of the Power of SQL. I came a situation where I wanted to move data from one table to another (without using DTS). How do you get the data moved over with just ONE SQL statement and no temp tables or complicated programming?

Consider the following example:
INSERT into foo2
(col, col2,col3)
select col,col2,col3
from foo1
where destination='foo2'
I hope that helps!

No comments: