如何在 Transact-SQL 中使用 IF ELSE 语句

在本文中,将介绍如何在 Transact-SQL 中使用 IF ELSE 语句。

IF ELSE 语句

T-SQL 中的 IF ELSE 语句是所有控制流语句中最基本的。 IF ELSE 语句根据条件执行一系列语句。

例子

declare

@emp_id int = 200,
@emp_sal money 
if(@emp_id>0 and @emp_id<100)
begin

print (' Name and salary ' )
select name,salary from oiremp where id = @emp_id
end
else

begin
print('employee id is not correct')
end
日期:2020-06-02 22:17:59 来源:oir作者:oir