sql - Insert distinct values from one table into another table -
so each distinct value in column of 1 table want insert unique value row of table.
list = select distinct(id) table0 distinct_id in list insert table1 (id) values (distinct_id) end
any ideas how go this?
whenever think doing in loop, step back, , think again. sql optimized work sets. can using set-based query without need loop:
insert dbo.table1(id) select distinct id dbo.table0;
there edge cases looping can make more sense, sql server matures , more functionality added, edge cases narrower , narrower...
Comments
Post a Comment