У меня есть следующий запрос, который показывает те клиенты, которые не имеют точного соответствия с другой системой:отчеты, которые не соответствуют между различными базами данных
select *
from CacheClients
Left Join CacheClientsOtherSystem on
CacheClients.[Client Number] = CacheClientsOtherSystem.Resident and
CacheClients.[First Name] = CacheClientsOtherSystem.[First name] and
CacheClients.[Last Name] = CacheClientsOtherSystem.[Last name] and
CacheClients.[DOB] = CacheClientsOtherSystem.[Date of Birth] and
CacheClients.[Street Address] = CacheClientsOtherSystem.[Street name] and
CacheClients.[Post Code] = CacheClientsOtherSystem.[Postcode] and
CacheClients.[Suburb] = CacheClientsOtherSystem.[City/Suburb] and
CacheClients.[State] = CacheClientsOtherSystem.[State] and
CacheClients.[Export Code] = CacheClientsOtherSystem.[Facility No] and
CacheClients.[Funding ID] = CacheClientsOtherSystem.[Accomodation History No] and
CacheClients.[Export Code] = CacheClientsOtherSystem.[Facility No] and
CacheClients.[Client Status] = CacheClientsOtherSystem.[Archived]
where [Export Code] = '420022' --412030
and ([Latest End Date] is null or [Latest End Date] > Convert(Date, GetDate()))
Проблема мне нужно решить оказывает сообщение столбец, который говорит, что он не соответствует для каждой отдельной строки, т. е. «Не соответствует в DOB, Post Code, State» в качестве примера.
Мне было интересно, есть ли у кого-нибудь умные идеи для достижения этого?
Лучшее, что я могу вспомнить несколько конкатенации 'case' заявление ... – sgeddes
' СЛУЧАЙ КОГДА CacheClientsOtherSystem [Номер клиента]. IS NULL THEN '[Номер клиента],' ELSE '' END + CASE WHEN CacheClientsOtherSystem. [Имя] IS NULL THEN '[Имя]' ELSE '' END + ..... ' –