No es demasiado difícil generar datos aleatorios, incluso en SQL
Por ejemplo, para obtener un nombre de usuario aleatorio de su tabla de perfiles de usuario.
BEGIN
-- get a random row from a table
DECLARE @username VARCHAR(50)
SELECT @username = [Username] FROM (
SELECT ROW_NUMBER() OVER(ORDER BY [Username]) [row], [Username]
FROM [UserProfile]
) t
WHERE t.row = 1 + (SELECT CAST(RAND() * COUNT(*) as INT) FROM [UserProfile])
print(@username)
END
Para generar un entero aleatorio...
BEGIN
-- get a random integer between 3 and 7 (3 + 5 - 1)
DECLARE @totalviews INT
SELECT @totalviews = CAST(RAND() * 5 + 3 as INT)
print(@totalviews)
END
Para generar una cadena varchar aleatoria
BEGIN
-- get a random varchar ascii char 32 to 128
DECLARE @videoname VARCHAR(160)
DECLARE @length INT
SELECT @videoname = ''
SET @length = CAST(RAND() * 160 as INT)
WHILE @length <> 0
BEGIN
SELECT @videoname = @videoname + CHAR(CAST(RAND() * 96 + 32 as INT))
SET @length = @length - 1
END
print(@videoname)
END
Y finalmente, una fecha aleatoria
BEGIN
-- get a random datetime +/- 365 days
DECLARE @uploadtime DATETIME
SET @uploadtime = GETDATE() + (365 * 2 * RAND() - 365)
print(@uploadtime)
END