我想用T-SQL语句打印一个九九乘法表,但是总是换行,哪位有好的方法让
2*1 2*2 在一行显示
declare @str varchar(max)
set @str = '1*1= 1 '+char(13)+'2*1= 2 2*2= 4 '
print @str
/******************
1*1= 1
2*1= 2 2*2= 4
char(13) 表示换行符
declare @str varchar(max)
declare @num1 int ,@num2 int
select @num1=1,@num2=1
while(@num1<10)
begin
set @num2=1
while(@num2<
=@num1)
begin
set @str = isnull(@str,'')+ltrim(@num1)+'*'+ltrim(@num2)+'='+right(
100+@num1*@num2,2)+' '
set @num2=@num2+1
end
set @num1=@num1+1
set @str = isnull(replace(@str,'=0','= '),'') + char(13)
end
print @str