sql打印99乘法表

declare @mul1 int, @mul2 int
declare @str varchar(4096)
set @mul1 = 1
while(@mul1 < 10)
begin
	set @mul2 = 1
	while(@mul2 <= @mul1)
	begin
		set @str = isnull(@str, '') + convert(varchar, @mul2) + '*' + convert(varchar, @mul1) + '=' + right(100 + @mul1 * @mul2, 2) + ' '
		set @mul2 = @mul2 +1
	end
	set @mul1 = @mul1 + 1
	set @str = replace(@str, '=0', '= ') + char(13)
end

print @str
转自 点击打开链接

你可能感兴趣的:(SQL)