Hi Wallace, I am always using ISNULL function for these cases when I am to compare.
Another possibility is to check for NULL explicitly: IF @var IS NULL BEGIN -- do stuff END ELSE BEGIN -- do other stuff END Cheers, jano On 18 January 2012 08:20, Wallace Turner <[email protected]> wrote: > Consider: > > declare @var bit > > if (select @var) <> 1 > print 'value is not equal to 1' > else > print 'value is 1' > > assuming ANSI_NULLS is on then the output is: > > value is 1 > > What are some common ways that people deal with this 'gotcha' ? eg > 1) don't use <> operator at all > 2) use ISNULL > > Please consider the case where the select is a (more) complex statement. > > > Regards > > Wal >
