SQL的经验教训

 declare @defaultGroup int
   select top 1 @defaultGroup=isnull([InvoiceGroup],0) from #t1 where ItemType=2
   print @defaultGroup

我原来以为,如果#t1里面没有ItemType=2的记录,应该也会将@defaultGroup赋值为0,

结果颠覆我的认知,@defaultGroup 是啥都没有,下面print 没有任何内容出来。

 

posted @ 2025-12-05 11:03  老飞飞  阅读(2)  评论(0)    收藏  举报