/*TWORZENIE nowych użytkowników ( [app].[users]) na podstawie starszych ( [users].[users])*/
BEGIN TRAN
Insert into app.users (id, AccessFailedCount, ConcurrencyStamp, email, EmailConfirmed, LockoutEnabled , NormalizedEmail, NormalizedUserName,PasswordHash,UserName, user_app_name)
select lower(u.userID), 0, 'a8c89468-e55e-4280-bb1d-aba604afc627', u.email, 0, 1, upper(u.email), upper(u.email),'xxxxxxxx', lower(u.email),'erp' from [user].[user] u
where u.email is not null and u.email like '%@%' and u.email not in (select email from app.users where email =u.email)
ROLLBACK TRAN