SQL IF DATENAME(weekday, GETDATE()) IN (N'Saturday', N'Sunday')SELECT'Weekend'; ELSESELECT'Weekday'; 有关更多示例,请参阅ELSE (IF...ELSE)。 示例:Azure Synapse Analytics 和 Analytics Platform System (PDW) 下面的示例使用IF...E
SQL IF 1 = 1 PRINT 'Boolean expression is true.' ELSE PRINT 'Boolean expression is false.'; 下面的示例具有一个布尔表达式(),该表达式为1 = 2false,因此输出第二个语句。 SQL IF 1 = 2 PRINT 'Boolean expression is true.' ELSE PRINT 'Boolean expression is false.'; GO ...
{sql_statement|statement_block} 任何Transact-SQL 语句或用语句块定义的语句分组。除非使用语句块,否则 IF 或 ELSE 条件只能影响一个 Transact-SQL 语句的性能。 若要定义语句块,请使用控制流关键字 BEGIN 和 END。 备注 IF...ELSE 构造可用于批处理、存储过程和即席查询。当此构造用于存储过程时,通常用于测试...
Impose les conditions d'exécution d'une instruction Transact-SQL. L'instruction Transact-SQL qui suit le mot clé IF et sa condition est exécutée si la condition est remplie, c'est-à-dire lorsque l'expression booléenne renvoie la valeur TRUE. Le mot clé facultatif ELSE introduit une ...
SQL Copy IF 1 = 1 PRINT 'Boolean expression is true.' ELSE PRINT 'Boolean expression is false.'; The following example has a Boolean expression (1 = 2) that is false, and therefore prints the second statement. SQL Copy IF 1 = 2 PRINT 'Boolean expression is true.' ELSE PRINT '...
SQL Copy IF 1 = 1 PRINT 'Boolean expression is true.' ELSE PRINT 'Boolean expression is false.'; The following example has a Boolean expression (1 = 2) that is false, and therefore prints the second statement. SQL Copy IF 1 = 2 PRINT 'Boolean expression is true.' ELSE PRINT '...
SQL Copy IF 1 = 1 PRINT 'Boolean expression is true.' ELSE PRINT 'Boolean expression is false.'; The following example has a Boolean expression (1 = 2) that is false, and therefore prints the second statement. SQL Copy IF 1 = 2 PRINT 'Boolean expression is true.' ELSE PRINT '...
SQL IF DATENAME(weekday, GETDATE()) IN (N'Saturday', N'Sunday')SELECT'Weekend'; ELSESELECT'Weekday'; For more examples, seeELSE (IF...ELSE). Examples: Azure Synapse Analytics and Analytics Platform System (PDW) The following example usesIF...ELSEto determine which of two responses to ...
EXECUTE--动态地执行SQL 语句 DESCRIBE--描述准备好的查询 ---局部变量 declare@idchar(10) --set @id = '10010001' select@id='10010001' ---全局变量 ---必须以@@开头 --IF ELSE declare@xint@yint@zint select@x=1@y=2@z=3 if@x>@y ...
EXECUTE--动态地执行SQL 语句 DESCRIBE--描述准备好的查询 ---局部变量 declare@idchar(10) --set @id = '10010001' select@id='10010001' ---全局变量 ---必须以@@开头 --IF ELSE declare@xint@yint@zint select@x=1@y=2@z=3 if@x>@y ...