My Technical Notes

Thursday, 31 January 2013

SQL Server Syntax Requires Blocks to have statements

What is wrong with the following lines of SQL:


IF 1 = 1
BEGIN
    
END;

?

The answer is that if we have a BEGIN END block, then we need to have at least one statement. e.g:


IF 1 = 1
BEGIN
  PRINT 'Hello world'
END;

No comments: