BEGIN…END block in SQL Server
问题 Are there any rules defined for grouping the T-SQL statements under the BEGIN...END block ? Because when I try the BEGIN...END block inside the CASE statement OR IIF statement, it fails. I need BEGIN...END block because there are multiple operations that I want to perform under the CASE result. SELECT CASE @ChargePaid WHEN 1 THEN BEGIN SELECT 'Paid' END WHEN 0 THEN BEGIN SELECT 'Not Paid' END END OR SELECT IIF( @ChargePaid > 0, BEGIN SELECT 'Paid' END , BEGIN SELECT 'Not Paid' END ) EDIT: IF