Considerando que pueden haber identificadores que no corresponden ya a ningún registro, este stored procedure devuelve un registro al azar de una tabla
CREATE PROCEDURE getRandomRecord AS SET NOCOUNT ON DECLARE @id int // del registro seleccionado DECLARE @max int // total de registros DECLARE @rnd float // número aleatorio DECLARE @sel int // número aleatorio entero // Averiguamos cuantos registros hay SELECT @max = count(*) FROM t_TABLE // Obtenemos un aleatorio enterio entre 0 y @max SET @rnd = @max * DatePart(ms, GetDate()) / 1000 SET @sel = cast(@rnd as int) // Obtenemos el identificador del registro en esa posición DECLARE crs SCROLL CURSOR FOR SELECT idRecord FROM t_TABLE OPEN crs FETCH ABSOLUTE @sel FROM crs INTO @id CLOSE crs DEALLOCATE crs // Selecionamos dicho registro SELECT * FROM t_TABLE WHERE idRecord = @id GO