注册 登录
编程论坛 SQL Server论坛

用sql写一个循环题怎么做。?

花脸 发布于 2017-06-04 17:27, 1747 次点击

2.使用T-SQL语言,输出:

*

***

*****

*******

*********
1 回复
#2
root_lord2017-06-07 22:47
declare @i as int
set @i = 1
while @i <= 20
begin
    declare @j as int
    set @j = 1
    declare @str as varchar(20)
    set @str = ''
    while @j <= @i
    begin
        set @str = @str +  '*'
        set @j = @j + 1
    end
    print @str
    set @i = @i + 2
end
1