declare @defaultGroup int select top 1 @defaultGroup=isnull([InvoiceGroup],0) from #t1 where ItemType=2 print @defaultGroup
我原来以为,如果#t1里面没有ItemType=2的记录,应该也会将@defaultGroup赋值为0,
结果颠覆我的认知,@defaultGroup 是啥都没有,下面print 没有任何内容出来。