Referral Problem with SQL Backend