if exists (select * from sys.syscolumns where name = 'Email' and id = object_id(N'dbo.UserProfile'))
    exec sp_executesql N'update ua
    set Email = up.Email
    from dbo.UserAccount ua
        inner join dbo.UserProfile up on ua.ID = up.UserID
    where up.Email is not null and ua.Email is null';