If FMTONLY is ON, all queries return zero rows, so a variable assignment in any select has no effect, and the variable keeps its previous value, which is NULL if it was never initialized. Here is another example which works in SQL2000, but at any rate you can query any table you have permission on.
DECLARE @FmtOnlyTest int
set @FmtOnlyTest = 0
SELECT count(*) AS C FROM dbo.sysobjects
SELECT @FmtOnlyTest = count(*) FROM dbo.sysobjects
IF ( @FmtOnlyTest = 0 ) BEGIN
SET FMTONLY OFF
PRINT 'NOW OFF'