1 SELECT vc_your_email,vc_our_ref_or_code 2 INTO #tmp 3 FROM( SELECT vc_your_email,vc_our_ref_or_code,ROW_NUMBER() OVER (PARTITION BY vc_your_email ORDER BY newid()) NUM FROM #ip_single_email_total 4 ) P WHERE NUM=1