Delete equal data from two tables in SQL Server -


i have 2 tables these columns:

table

id | name  | salary   1  | test1 | 100   2  | test2 | 200   3  | test3 | 300 

table b

id | name  | salary   1  | test1 | 100   2  | test2 | 200   4  | test4 | 400 

i want delete similar data 2 tables (without using joins). when query

select *    select *  b 

i should result:

table

id | name  | salary    3  | test3 | 300 

table b

id | name  | salary    4  | test4 | 400 

any appreciated. in advance.

ps : i'm going load table around 10 millions rows

you better replace "delete lots of rows" "create new table rows remaining".

very simple if sql server version supports except:

select * newa except select * b ;  select * newb b except select * ; 

see fiddle

exists simplifies null treatment.


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -