set 赋值问题

usernamezero usernamezero 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
如下定义变量
--组合条件(盘点)
declare @ChaXunZuHe varchar(4000);
--组合条件出,入,调库
declare @ChuRuTiaoZuHe varchar(4000);
下边的赋值方法
set @ChaXunZuHe=(' select shijishuliang,CangKuBianHao,CangKu,BianHao,MingChen,GuiGe,SuoShuGongChang from ( '
+@FromTable+' )A'+' where 1=1 ')
--print @ChaXunZuHe;

--组合出,入,调库中的查询
set @ChuRuTiaoZuHe= (' select * from View_ImEx where 1=1 ')
--print @ChuRuTiaoZuHe;
if len(rtrim(@CaiLiaoBianHao))<>0
begin
--材料编号不为空 盘点组合条件
set @strCalLiaoBianHao=(' and BianHao='+''+''''+@CaiLiaoBianHao+'''');
--材料编号不为空 出入调库组合条件
set @strCRTCaiLiaoBianHao=(' and CaiLiaoBianHao='+''+''''+@CaiLiaoBianHao+'''');
set @ChaXunZuHe=(@ChaXunZuHe+@strCalLiaoBianHao);
set @ChuRuTiaoZuHe=(@ChuRuTiaoZuHe+@strCRTGongChangBianHao);
print 1
print @ChuRuTiaoZuHe
print 2
end

print @ChuRuTiaoZuHe 这时候打印为空的为什么 我的这个if 没有问题 此变量不为空我打印出来看了
而且pring @ChaXunZuHe 里边是有值的
...全文
评论 3
收藏 已收藏
分享
返回顶部
usernamezero
非技术版 11,847 成员 33,667 内容