insert into NewKms8081..members
SELECT
(select u2.Id from SecurityKms8081..users u2
join SecurityKms8081..Import_users_barghGharb i2 on i2.code_personeli=u2.PersonnelNumber
) as [Id]
, NULL as [SSN]
, NULL as [IdentityNumber]
, NULL as [BirthdayYear]
, NULL as [Address]
, NULL as [PhoneNumber2]
, NULL as [PhoneNumber3]
, NULL as [EmploymentDate]
, NULL as [LastEducationalCertificationId]
--, (select u2.Id from SecurityKms8081..users u2 where u2.PersonnelNumber=i.code_personeli ) as [MemberActivityInfoId]
, NEWID() as [MemberActivityInfoId]
--, (select u2.Id from SecurityKms8081..users u2 where u2.PersonnelNumber=i.code_personeli ) as [UserDataId]
, NEWID() as [UserDataId]
, NULL as [PhotoPath]
, '0DF87534-A229-4635-BF58-FC219F7A8E4E' as [OrganizationId]
, NULL as [AttachmentPictureId]
, NULL as [VisitId]
FROM SecurityKms8081..Import_users_barghGharb i
join SecurityKms8081..users u on i.code_personeli=u.PersonnelNumber
where u.Id not in
(
select m.id from NewKms8081..members m
)