99乘法表

来源:互联网 发布:网页数据采集软件 编辑:程序博客网 时间:2024/04/29 15:13
DECLARE @x INT,@y INT,@c VARCHAR(200)SET @x=1WHILE @x<=9BEGINSET @y=1SET @c=''WHILE @y<=@xBEGIN SET @c=@c+CAST(@y AS NVARCHAR(10))+'*'+CAST(@x AS NVARCHAR(10))+'='+CAST(@x*@y AS NVARCHAR(10))+' 'SET @y=@y+1       END     SET @x=@x+1PRINT @c+CHAR(10)END

select(case when a>0 then '1*'+a+'='+ltrim(a*1) end) [1],(case when a>1 then '2*'+a+'='+ltrim(a*2) end) [2],(case when a>2 then '3*'+a+'='+ltrim(a*3) end) [3],(case when a>3 then '4*'+a+'='+ltrim(a*4) end) [4],(case when a>4 then '5*'+a+'='+ltrim(a*5) end) [5],(case when a>5 then '6*'+a+'='+ltrim(a*6) end) [6],(case when a>6 then '7*'+a+'='+ltrim(a*7) end) [7],(case when a>7 then '8*'+a+'='+ltrim(a*8) end) [8],(case when a>8 then '9*'+a+'='+ltrim(a*9) end) [9]from   (    select ltrim(number) a from master..spt_values     where type='p' and number between 1 and 9) t