I have two tables A and B with 30 columns (same variable names, data for different year), no primary key, almost a million records each.
I want to compare A.X1
with B.X1
(nvarchar8
, contains spaces, -, letter and numbers) and insert the outer join results in another table C (with same 30 columns) so I have all rows of A and where B!=A on B.X1).
Example:
Table A
X1 X2 X3 ..... X30
11 E R ..... G
12 R 4 L
13 S 5 NULL
14 D T NULL
Table B
X1 X2 X3 ..... X30
11 E R ..... G
12 R 4 L
15 R2 56 NULL
16 R1 T1 NULL
Resulting table C
X1 X2 X3 ..... X30
11 E R ..... G
12 R 4 L
13 S 5 NULL
14 D T NULL
15 R2 56 NULL
16 R1 T1 NULL
How do I do that.
I tried
INSERT INTO C
SELECT *
from A
full outer join B
on A.X1 = B.X1
Error I get
Msg 213, Level 16, State 1, Line 1
Insert Error: Column name or number of supplied values does not match table definition.
I have C created, which is currently empty.