sp_attachsubscription is used in snapshot replication, transactional replication, and merge replication.
A subscription cannot be attached to the publication if the publication retention period has expired. If a subscription with an elapsed retention period is specified, an error occurs either when the subscription is attached or when it is first synchronized. Publications with a publication retention period of 0 (never expire) are ignored.