Technical Article

Just for fun

,

It's a random word generator. Just pass a number of words to generate and laugh.

 

peter

create proc RndWord @i int
as
 begin
  declare  @j int, @w int,@flip int,@c varchar(16),@vowels char(6),@cons char(20)
  select @i=0, @j=0,@flip =0,@c='',@vowels='aeiouy',@cons='bcdfghjklmnpqrstvwxz';
  while @i<10
   begin
    set @w=round(rand()*16,0)
    while @j<=@w
begin
         set @c =case @flip
  when 0 then @c+case @j 
                 when 0 then  upper(substring(@cons,cast(round(rand()*19,0) as int)+1,1)) 
                 else substring(@cons,cast(round(rand()*19,0) as int)+1,1)
                                end
  when 1 then @c+case @j 
when 0 then  upper(substring(@vowels,cast(round(rand()*5,0) as int)+1,1)) 
else substring(@vowels,cast(round(rand()*5,0) as int)+1,1)
       end
                 end;
         set @j=@j+1;
 set @flip=(@flip+1)%2;
end
  print @c;
  set @c='';
  set @j=0
  set @i=@i+1;
 end
 return
end
go

exec RndWord 10

Rate

4.25 (4)

You rated this post out of 5. Change rating

Share

Share

Rate

4.25 (4)

You rated this post out of 5. Change rating