IF Isnull( @wareclause ,'') <> '' Set @wareclause = ' Where ' + @wareClause Exec( 'Insert #Ware(warecode,trademarkcode,specification,warename ) Select warecode ,trademarkcode,specification,warename From sawarecode ' + @wareclause )
IF Isnull( @Depart ,'') <> '' Set @Depart = ' Where ' + @Depart exec('insert #dept(deptcode) select DepartmentCode from stdepartment'+@depart)
select saTrademark.TrademarkName,specification,warename from #Ware ,saTrademark where #ware.trademarkcode=saTrademark.TrademarkCode and warecode not in (select warecode from whStockManage where WareHouseID in (select deptcode from #dept) ) --saTrademark为品牌表 whStockManage 为库存表