Merge two SQL tables

  • Hi,


    Could you help me with the following?
    I have two SQL tables that I fill up with a VB script running on the 2 machines where the SQL servers are running.
    The tables are identical in number of columns and i need to fill up one them with data out of the other:
    In the first table I have (I limited the columns here):
    ID Date Time OrderNr QualityRef BobPos BobNr
    22 10.06.2017 15:41:33 xyz abcd 0 0
    23 10.06.2017 15:42:31 xyz abcd 0 0
    24 10.06.2017 15:43:45 xyz abcd 0 0
    In the other table I have:
    ID Date Time OrderNr QualityRef BobPos BobNr
    99 10.06.2017 15:41:22 0 0 09 10
    100 10.06.2017 15:42:51 0 0 09 10
    101 10.06.2017 15:43:36 0 0 09 10
    Now I would like to have this:
    ID Date Time OrderNr QualityRef BobPos BobNr
    xx 10.06.2017 15:41:xx xyz abcd 09 10
    xy 10.06.2017 15:42:yy xyz abcd 09 10
    xz 10.06.2017 15:43:zz xyz abcd 09 10
    As you can see:
    * table need to be combined based on date and time (not taking the seconds into account)
    * "0" need to be replaced by the values of the other table


    I can't seem to work this out immediately with merge tools under 'data - new query - combine queries' as provided with excel 2016
    Solution can be in Excel or directly in SQL taking into account that the tabel are another SQL server.


    Thanks,
    Tom.