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

Popular posts from this blog

html - How to style widget with post count different than without post count -

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

javascript - storing input from prompt in array and displaying the array -