{ sql_statement| statement_block } 任何Transact-SQL 语句或用语句块定义的语句分组。除非使用语句块,否则 IF 或 ELSE 条件只能影响一个 Transact-SQL 语句的性能。 若要定义语句块,请使用控制流关键字 BEGIN 和 END。 注释 IF...ELSE 构造可用于批处理、存储过程和即席查询。当此构造用于存储过程时,通常用于...
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...ELSE,根据DimProduct表中各项的权重来决定向用户显示两个响应中的...
CLOSE--关闭游标 PREPARE--为动态执行准备SQL 语句 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 print'...
這是藉由使用陳述式區塊加以定義的任何 Transact-SQL 陳述式或陳述式分組。除非使用陳述式區塊,否則,IF 或 ELSE 條件只會影響一個 Transact-SQL 陳述式的效能。 若要定義陳述式區塊,請使用流程控制關鍵字 BEGIN 和 END。 備註 您可以在批次、預存程序和特定查詢中使用 IF...ELSE 建構。當在預存程序中使用這個...
syntaxsql IFboolean_expression{sql_statement|statement_block} [ELSE{sql_statement|statement_block} ] Nota Para exibir a sintaxe do Transact-SQL para o SQL Server 2014 (12.x) e versões anteriores, confira aDocumentação das versões anteriores. ...
syntaxsql IFboolean_expression{sql_statement|statement_block} [ELSE{sql_statement|statement_block} ] Arguments boolean_expression An expression that returnsTRUEorFALSE. If theboolean_expressioncontains aSELECTstatement, theSELECTstatement must be enclosed in parentheses. ...
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 ...
SQL database in Microsoft Fabric Imposes conditions on the execution of a Transact-SQL statement. The Transact-SQL statement that follows anIFkeyword and its condition is executed if the condition is satisfied: the Boolean expression returnsTRUE. The optionalELSEkeyword introduces another Transact-SQL...
SQL database in Microsoft Fabric Imposes conditions on the execution of a Transact-SQL statement. The Transact-SQL statement that follows anIFkeyword and its condition is executed if the condition is satisfied: the Boolean expression returnsTRUE. The optionalELSEkeyword introduces another Transact-SQL...
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 '...