我是T-SQL的新手,我有一个要求,即我必须使用功能或存储过程在SQL Server中生成数百万个唯一的随机伪造电子邮件ID。
使用JAVA,我创建了一个程序,该程序可以生成50个唯一的电子邮件ID(如下所述),但是我希望在SQL Server中使用相同的程序。
您能协助我如何使用T-SQL进行实施吗?任何帮助将不胜感激。
package com.ing.tdm;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import java.util.StringTokenizer;
import org.apache.commons.lang3.RandomStringUtils;
public class EmailGenerator {
public static String getEmailDomains(){
String randomElement = "";
String strOfEmailDomains = "aol.com, att.net, comcast.net, facebook.com, gmail.com, gmx.com, googlemail.com, google.com, hotmail.com, hotmail.co.uk, mac.com, me.com, mail.com, msn.com, live.com, sbcglobal.net, verizon.net, yahoo.com, yahoo.co.uk, email.com, fastmail.fm, games.com, gmx.net, hush.com, hushmail.com, icloud.com, iname.com, inbox.com, lavabit.com, love.com , outlook.com, pobox.com, protonmail.com, rocketmail.com, safe-mail.net, wow.com , ygm.com , ymail.com, zoho.com, yandex.com, bellsouth.net, charter.net, cox.net, earthlink.net, juno.com, btinternet.com, virginmedia.com, blueyonder.co.uk, freeserve.co.uk, live.co.uk, ntlworld.com, o2.co.uk, orange.net, sky.com, virgin.net, wanadoo.co.uk, bt.com, sina.com, sina.cn, qq.com, naver.com, hanmail.net, daum.net, nate.com, yahoo.co.jp, yahoo.co.kr, yahoo.co.id, yahoo.co.in, yahoo.com.sg, yahoo.com.ph, 163.com, 126.com, aliyun.com, foxmail.com, hotmail.fr, live.fr, laposte.net, yahoo.fr, wanadoo.fr, orange.fr, gmx.fr, sfr.fr, neuf.fr, free.fr, gmx.de, hotmail.de, live.de, online.de, t-online.de , web.de, yahoo.de, libero.it, virgilio.it, hotmail.it, aol.it, tiscali.it, alice.it, live.it, yahoo.it, email.it, tin.it, poste.it, teletu.it, mail.ru, rambler.ru, yandex.ru, ya.ru, list.ruhotmail.be, live.be, skynet.be, voo.be, tvcablenet.be, telenet.be, hotmail.com.ar, live.com.ar, yahoo.com.ar, fibertel.com.ar, speedy.com.ar, arnet.com.ar, yahoo.com.mx, live.com.mx, hotmail.es,yahoo.com.ar, fibertel.com.ar, speedy.com.ar, arnet.com.ar, yahoo.com.mx, live.com.mx, hotmail.es, hotmail.com.mx, prodigy.net.mx, yahoo.com.br, hotmail.com.br, outlook.com.br, uol.com.br, bol.com.br, terra.com.br, ig.com.br, itelefonica.com.br, r7.com, zipmail.com.br, globo.com, globomail.com, oi.com.br";
StringTokenizer st = new StringTokenizer(strOfEmailDomains, ",");
Random rand = new Random();
List<String> givenList = new ArrayList<String>();
while(st.hasMoreElements()){
String emaildomain = (String) st.nextElement();
givenList.add(emaildomain);
}
if(null!=givenList && givenList.size() > 0){
int randomIndex = rand.nextInt(givenList.size());
randomElement = givenList.get(randomIndex);
}
return randomElement;
}
public static String generateRandomEmail(int length) {
String emailId = "";
String allowedChars = "abcdefghijklmnopqrstuvwxyz" + "1234567890";
String allowedSpecialChars = "_-.";
String temp = RandomStringUtils.random(length, allowedChars);
emailId = (temp.substring(0, temp.length() - 9)
+Character.toString((RandomStringUtils.random(length, allowedSpecialChars)).charAt(0))
+temp.substring(12, 18)
+"@"+getEmailDomains()).replaceAll("\\s","");
System.out.println(emailId);
return emailId;
}
public static void main(String[] args) {
for (int i = 0; i < 50; i++) {
generateRandomEmail(20);
}
}
}
答案 0 :(得分:3)
如果您真的想使用SQL进行此操作,请尝试以下方法之一...
DECLARE @randomString VARCHAR(255)
SELECT
@randomString = CONVERT(VARCHAR(255), NEWID())
PRINT @randomString
OR
DECLARE @Length INT = 25
PRINT LEFT(REPLACE(NEWID(), '-', ''), @Length)
答案 1 :(得分:0)
您可以将CROSS JOIN
与NEWID()
一起生成大量电子邮件地址。这一次一次生成30k +电子邮件,直到达到或超过目标数量-大约需要一秒钟才能达到1019304个电子邮件地址(演示:http://rextester.com/GJS41165)
DECLARE @targetCount INT = 1000000
CREATE TABLE #emailTableTemp (fakeEmail VARCHAR(100))
WHILE (SELECT COUNT(1) FROM #emailTableTemp) < @targetCount
BEGIN
INSERT INTO #emailTableTemp
SELECT CONCAT(t2.prefix,t1.email) AS fakeEmail FROM
(VALUES ('aol.com'),('att.net'),('comcast.net'),('facebook.com'),('gmail.com'),('gmx.com'),('googlemail.com'),('google.com'),('hotmail.com'),('hotmail.co.uk'),('mac.com'),('me.com'),('mail.com'),('msn.com'),('live.com'),('sbcglobal.net'),('verizon.net'),('yahoo.com'),('yahoo.co.uk'),('email.com'),('fastmail.fm'),('games.com'),('gmx.net'),('hush.com'),('hushmail.com'),('icloud.com'),('iname.com'),('inbox.com'),('lavabit.com'),('love.com '),('outlook.com'),('pobox.com'),('protonmail.com'),('rocketmail.com'),('safe-mail.net'),('wow.com '),('ygm.com '),('ymail.com'),('zoho.com'),('yandex.com'),('bellsouth.net'),('charter.net'),('cox.net'),('earthlink.net'),('juno.com'),('btinternet.com'),('virginmedia.com'),('blueyonder.co.uk'),('freeserve.co.uk'),('live.co.uk'),('ntlworld.com'),('o2.co.uk'),('orange.net'),('sky.com'),('virgin.net'),('wanadoo.co.uk'),('bt.com'),('sina.com'),('sina.cn'),('qq.com'),('naver.com'),('hanmail.net'),('daum.net'),('nate.com'),('yahoo.co.jp'),('yahoo.co.kr'),('yahoo.co.id'),('yahoo.co.in'),('yahoo.com.sg'),('yahoo.com.ph'),('163.com'),('126.com'),('aliyun.com'),('foxmail.com'),('hotmail.fr'),('live.fr'),('laposte.net'),('yahoo.fr'),('wanadoo.fr'),('orange.fr'),('gmx.fr'),('sfr.fr'),('neuf.fr'),('free.fr'),('gmx.de'),('hotmail.de'),('live.de'),('online.de'),('t-online.de '),('web.de'),('yahoo.de'),('libero.it'),('virgilio.it'),('hotmail.it'),('aol.it'),('tiscali.it'),('alice.it'),('live.it'),('yahoo.it'),('email.it'),('tin.it'),('poste.it'),('teletu.it'),('mail.ru'),('rambler.ru'),('yandex.ru'),('ya.ru'),('list.ruhotmail.be'),('live.be'),('skynet.be'),('voo.be'),('tvcablenet.be'),('telenet.be'),('hotmail.com.ar'),('live.com.ar'),('yahoo.com.ar'),('fibertel.com.ar'),('speedy.com.ar'),('arnet.com.ar'),('yahoo.com.mx'),('live.com.mx'),('hotmail.es,yahoo.com.ar'),('fibertel.com.ar'),('speedy.com.ar'),('arnet.com.ar'),('yahoo.com.mx'),('live.com.mx'),('hotmail.es'),('hotmail.com.mx'),('prodigy.net.mx'),('yahoo.com.br'),('hotmail.com.br'),('outlook.com.br'),('uol.com.br'),('bol.com.br'),('terra.com.br'),('ig.com.br'),('itelefonica.com.br'),('r7.com'),('zipmail.com.br'),('globo.com'),('globomail.com'),('oi.com.br')) t1(email)
CROSS JOIN (VALUES
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),
(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@')),(CONCAT(REPLACE(CONVERT(VARCHAR(50), NEWID()),'-',''),'@'))
) t2(prefix)
END
SELECT COUNT(1) FROM #emailTableTemp
SELECT TOP 10 * FROM #emailTableTemp ORDER BY fakeEmail
DROP TABLE #emailTableTemp
答案 2 :(得分:0)
嗨,我想出了一个更加困难的解决方案,但我认为它更适合您的需求。
我有三个临时表:
创建表格后,我使用递归cte 50行(如果需要,可以执行更多操作)生成带有随机电子邮件长度和mailid的表。然后,我为allowChar表中的每个id生成一个随机的id。然后,将生成的id与allowChar表连接起来,并在单行中用“ for xml path”连接单个字符。 对于emailDomain和allowedSpecialChar,我几乎以相同的方式进行。最后,我将所有内容连接到一个有效的电子邮件地址。
CREATE TABLE Source
(
[ID1] INT,
[ID2] INT
);
INSERT INTO Source ([ID1], [ID2])
VALUES (1, 2), (2, 3), (4, 5),
(2, 5), (6, 7)
您还没有任何疑问吗?我帮你。