Transact-SQL WHILE 语句示例

declare @num int
declare @countr int=1
declare @temp int

declare @result varchar(15)
select @num = 2
while(@countr<=10)
begin

select @temp = @num*@countr
print convert(char(10),@temp)
select @countr = @countr + 1
end
如何在 Transact-SQL 中使用 WHILE 语句

在本文中,将介绍如何在 T-SQL 中使用 while 语句。

WHILE 声明

While 语句多次执行一系列语句。 只要条件为真,就会执行 while 主体中的语句。

while (condition)
begin
Statement 1
Statement 2
Statement 3
.
.
Statement n
end
日期:2020-06-02 22:18:01 来源:oir作者:oir