Retrieve Data that do not exist in the primary table, exist in the secondary only Problem:
I would like to retrieve the value that do not exist in the list table b but it exist in table a.  

I don't know how to do it.

Please remember that the data will change very often.



SELECT [id]
      ,[name]
      ,[email]
      ,[phone]
      ,[cellphone]
      ,[none]
  FROM [test].[dbo].[datatable]

SELECT [id]
      ,[name]
      ,[email]
      ,[phone]
      ,[cellphone]
      ,[none]
  FROM [test].[dbo].[datatable2]
Use EXCEPT:

SELECT [id]
  ,[name]
  ,[email]
  ,[phone]
  ,[cellphone]
  ,[none]
FROM [test].[dbo].[datatable1]
EXCEPT
SELECT [id]
  ,[name]
  ,[email]
  ,[phone]
  ,[cellphone]
  ,[none]
FROM [test].[dbo].[datatable]


This will give you all the rows that exists in datatable1 but do not exist in datatable.

If you want it only for the keys then you should use

select t1.[id]
from   [test].[dbo].[datatable1] AS t1
where  not exists (select t2.[id]
                   from   [test].[dbo].[datatable] AS t2
                   where t2.[id] = t1.[id]);