if是条件分支语句,
IF
语句1
语句2
还可与ELSE 合用
具体的HI 我
declare @i int
set @i=datepart(hh,getdate())
if @i<12
print '上午'
else
print '下午'
IF @cost <= @compareprice
BEGIN
PRINT 'These products can be purchased for less than
$'+RTRIM(CAST(@compareprice AS varchar(20)))+'.'
END
ELSE
PRINT 'The prices for all products in this category exceed
$'+ RTRIM(CAST(@compareprice AS varchar(20)))+'.'