-- Since Comp.ai.philosophy is still dead
-- I thought I would introduce a more random
-- version. Unfortunately, while I thought I
-- owned a developers edition of sql server
-- my home version does not work so this
-- code is untested.
declare @x varchar(max);
declare @x2 varchar(max);
declare @i int;
declare @q varchar(1);
declare @l int;
declare @r int;
-- I use @x to store the program
set @x = '''-- Since Comp.ai.philosophy is still dead
-- I thought I would introduce a more random
-- version. Unfortunately, while I thought I
-- owned a developers edition of sql server
-- my home version does not work so this
-- code is untested.
declare @x varchar(max);
declare @x2 varchar(max);
declare @i int;
declare @q varchar(1);
declare @l int;
declare @r int;
-- I use @x to store the program
set @x = ;
-- @q is the quote character
set @q = LEFT(@x,1);
-- the second caracter is the pipe character
-- @i is set to the second instance of the pipe caracter
set @i = CHARINDEX(substring(@x,2,1),@x,3);
-- slice and dice
set @l = round(rand()*(len(@x)-2),0);
set @r = round(rand()*(len(@x)-2),0);
set @x2 = substring(@x,3,@l) + @q + @q + @x + @q + right(@x,@r);
-- does the new string execute
begin try
exec(left(@x2,len(@x)-10)
end try
begin catch
set @x2 = substring(@x,3,@i-3) + @q + @q + @x + @q + right(@x,len(@x)-@i);
end catch;
-- now print the random string if it executes
-- otherwise print the known string;
print @x2;';
-- @q is the quote character
set @q = LEFT(@x,1);
-- the second caracter is the pipe character
-- @i is set to the second instance of the pipe caracter
set @i = CHARINDEX(substring(@x,2,1),@x,3);
-- slice and dice
set @l = round(rand()*(len(@x)-2),0);
set @r = round(rand()*(len(@x)-2),0);
set @x2 = substring(@x,3,@l) + @q + @q + @x + @q + right(@x,@r);
-- does the new string execute
begin try
exec(left(@x2,len(@x)-10)
end try
begin catch
set @x2 = substring(@x,3,@i-3) + @q + @q + @x + @q + right(@x,len(@x)-@i);
end catch;
-- now print the random string if it executes
-- otherwise print the known string;
print @x2;