I've searched for hours with no specific answer to my problem. 

I have two tables, for example:

Table A

```
DateAndTime             ms  us  F1      F2      F3
2012-07-07 00:00:00.000 0   0   1       1       1   
2012-07-07 01:07:40.000 750 361 1       0       1   
2012-07-07 01:07:41.000 50  11  1       0       1  
2012-07-07 01:08:35.000 850 998 1       0       0
2012-07-07 01:08:36.000 50  83  1       0       0
2012-07-07 01:08:59.000 250 26  0       0       0

```

Table B

```
DateAndTime             ms  us  F4      F5      F6
2012-07-07 00:00:00.000 0   0   1869    11      2247
2012-07-07 00:00:00.000 0   588 1869    15      2247
2012-07-07 00:05:14.000 987 359 1869    13      2251
2012-07-07 00:05:16.000 45  493 1869    11      2247
2012-07-07 00:14:15.000 985 557 1869    11      2157
2012-07-07 00:14:16.000 945 179 1869    11      2279

```

The result I'm looking for is to merge these two tables:

Result Table

```
DateAndTime             ms  us  F1      F2      F3      F4      F5      F6
2012-07-07 00:00:00.000 0   0   1       1       1       1869    11      2247
2012-07-07 00:00:00.000 0   588 NULL    NULL    NULL    1869    15      2247 
2012-07-07 00:05:14.000 987 359 NULL    NULL    NULL    1869    13      2251
2012-07-07 00:05:16.000 45  493 NULL    NULL    NULL    1869    11      2247
2012-07-07 00:14:15.000 985 557 NULL    NULL    NULL    1869    11      2157
2012-07-07 00:14:16.000 945 179 NULL    NULL    NULL    1869    11      2279
2012-07-07 01:07:40.000 750 361 1       0       1       NULL    NULL    NULL     
2012-07-07 01:07:41.000 50  11  1       0       1       NULL    NULL    NULL     
2012-07-07 01:08:35.000 850 998 1       0       0       NULL    NULL    NULL  
2012-07-07 01:08:36.000 50  83  1       0       0       NULL    NULL    NULL  
2012-07-07 01:08:59.000 250 26  0       0       0       NULL    NULL    NULL  

```

The PRIMARY KEY in both tables is made up of (DateAndTime, ms, us).

If both tables have the same primary key then the data can be merged into the same row, otherwise there should just be new rows with NULLs where there is no data.

The column names are not always the same so I would have to build the query dynamically using C# and then execute it. I'm just trying to do as much of the work on the SQL server side before I start processing the data in C#.