create table Bob ( i int, x float, y float ) declare @j int set @j = 1 while @j < 100 begin insert into Bob select @j, @j, 3.27*@j+5*rand() set @j = @j + 1 end select (count(x)*sum(x*y)-sum(x)*sum(y)) /(count(x)*sum(x*x) - sum(x)*sum(x)) as slope, (sum(y)*sum(x*x) - sum(x)*sum(x*y)) /(count(x)*sum(x*x) - sum(x)*sum(x)) as intercept from Bob go drop table Bob