A morphism is a separated morphism when its diagonal morphism
is a closed immersion.
For the requested example, take the affine plane with doubled origin: glue two copies by the identity on
The opens and are affine, while their intersection is the punctured affine plane, which is not affine. Indeed, its regular functions are still ; if it were affine, the canonical map to would be an isomorphism, contrary to the missing origin. The resulting scheme is not separated: in a separated scheme, the intersection of two affine opens is the inverse image of the closed diagonal inside their affine product and is therefore affine.
Fix and choose affine opens and with . The open subset of contains . If and , its diagonal is induced by the surjection
so it is a closed immersion. Hence every diagonal morphism is locally a closed immersion into an open subset, and therefore is a locally closed immersion.
For , the product is and the diagonal is . Its complement is the principal affine open
Take instead the separated scheme . The complement of its diagonal in is , where the removed diagonal has codimension two. Its global functions still form the polynomial ring of . Were the complement affine, its canonical morphism to of this ring would identify it with all of , which is impossible. Thus this diagonal complement is not affine.