select @IDCHAR = case when @IDCHAR is null then max(编号) else case when max(编号)>@IDCHAR then max(编号) else @IDCHAR end end from 调拨单 with(tablock)
select getdate(),@yfbh,@ghbh,@yfhh,@yfph,@yfsl,'从'+rtrim(k.名称)+'进货',
round(@yfje,2),round(@yfbhsje,2),0,0,case when @yfye is null then 0 else @yfye end+round(@yfje,2),
case when @yfbhsye is null then 0 else @yfbhsye end+round(@yfbhsje,2),@xxsm, @记帐人 from 供货商清单 as k where k.供货商编号=@ghbh
select (case when company_name is null then member_name else company_name end) as D, user_ID,member_name,company_name from (select user_ID ,member_name ,member_ID from sql8_user left
join sql8_member on user_ID=Member_Userid ) as D left join sql8_company on D.[user_ID]=sql8_company .company_userid