• Thom A - Thursday, August 17, 2017 5:36 AM

    This is so much a SQL question, but more C#, so I'm not sure how much of a useful response you'll get here (as a SQL Server forum).

    If, however, you could entertain using SQL Server to do the task though:
    I'd suggest importing the Excel Document to your SQL Server. This is "easily" achieved by using SSIS  (I say easily as the ACE drivers used for interacting with Excel can be quirky at the best of times and I don't know what your data looks like). Then, in SQL you can compare the 2 tables by using an EXIST statement.

    Without knowing anything about your data, this is a sample, but in very simple terms your query might look something like:
    SELECT *
    FROM [YourImportedTable] YIT
    WHERE NOT EXISTS (SELECT *
                      FROM [YourSourcerTable] YST
                      WHERE YST.Id = YIT.Id);

    This would return all the records in the data you imported (from Excel), where the ID does not exist in your original Source Table.

    Thanks Chief, i just tried it didnt work, i want to try and explain properly,
    in sql i have a table called PFMembers that keeps members of a provident fund and their ids
    say the next month i am supplied a list that contains same list of members (in my PFMembers) plus additional new members which are not registered in my PFMember table , (due to size of the list i may not know these new names)
    in c#, i have two gridviews, one will display the upload from excel which will contain both members registered in my PFMember and the new additional members, my question is i want to display in the 2nd gridview those new additional members. (this new members are no where in an sql table but just displayed in a gridview)