In the following script one out of six semicolons does not parse. Can you guess which one we need to remove without running it or scrolling down for the answer? Does it make sense to you?
BEGIN TRY ;
PRINT 'Inside TRY' ;
END TRY ;
BEGIN CATCH ;
PRINT 'Inside CATCH' ;
END CATCH ;
BEGIN TRY ;
PRINT 'Inside TRY' ;
-- the wrong semicolon commented
END TRY --;
BEGIN CATCH ;
PRINT 'Inside CATCH' ;
END CATCH ;
Comment Notification
If you would like to receive an email when updates are made to this post, please register here
Subscribe to this post's comments using
About Alexander Kuznetsov
Alex Kuznetsov has been working with object oriented languages, mostly C# and C++, as well as with databases for more than a decade. He has worked with Sybase, SQL Server, Oracle and DB2. He regularly blogs on sqlblog.com, mostly about database unit testing, defensive programming, and query optimization.
Alex has written a book entitled "Defensive Database Programming with Transact-SQL" and several articles on simple-talk.com and devx.com. Currently he works at DRW Trading Group in Chicago, where he leads a team of developers, practicing agile development, defensive programming, TDD, and database unit testing.