gcbh 工厂编号,clbh 材料编号,kcsl 库存数量等等·select gcbh,clbh,
sum(kcsl) as kcsl,sum(lskcsl) as lskcsl,sum(rksl) as rksl,sum(tlsl) as tlsl,
sum(cksl) as cksl,sum(cklssl) as cklssl,sum(kctzsl) as kctzsl,sum(lskctzsl) as lskctzsl 
from(
select gcbh,clbh,
sum(isnull(kcsl,0))as kcsl,sum(isnull(lskcsl,0)) as lskcsl,
0 as rksl,0 as tlsl,0 as cksl,0 as cklssl,0 as kctzsl,0 as lskctzsl 
from 
erp_kc_clkc 
where 
gcbh like :gcbh and clbh like :clbh 
group by gcbh,clbh
union all
select gcbh,clbh,
0 as kcsl,0 as lskcsl,sum(isnull(rksl,0))as rksl,0 as tlsl,
0 as cksl,0 as cklssl,0 as kctzsl,0 as lskctzsl 
from 
erp_sc_clrkd a,erp_sc_clrk_detail b
where 
a.rkdh=b.rkdh and a.shzt='1' and gcbh like :gcbh and clbh like :clbh and rkrq>= :rq1 and  rkrq<= :rq2 
group by gcbh,clbh
union all
select gcbh,clbh,
0 as kcsl,0 as lskcsl,0 as rksl,sum(isnull(tlsl,0))as tlsl,
0 as cksl,0 as cklssl,0 as kctzsl,0 as lskctzsl 
from 
erp_sc_cltld a,erp_sc_cltld_detail b
where 
a.tldh=b.tldh and a.shzt='1' and gcbh like :gcbh and clbh like :clbh and tlrq>= :rq1 and  tlrq<= :rq2 
group by gcbh,clbh
union all
select gcbh,clbh,
0 as kcsl,0 as lskcsl,0 as rksl,0 as tlsl,
sum(isnull(cksl,0))as cksl,sum(isnull(cklssl,0))as cklssl,0 as kctzsl,0 as lskctzsl 
from 
erp_sc_clckd a,erp_sc_clck_detail b
where 
a.ckdh=b.ckdh and a.shzt='1' and gcbh like :gcbh and clbh like :clbh and ckrq>= :rq1 and  ckrq<= :rq2 
group by gcbh,clbh
union all
select gcbh,clbh,
0 as kcsl,0 as lskcsl,0 as rksl,0 as tlsl,
sum(isnull(kcsl,0)-isnull(kcsl1,0)) as kctzsl,0 as cksl,0 as cklssl,
sum(isnull(lskcsl1,0)-isnull(lskcsl,0)) as lskctzsl 
from 
erp_sc_cltzd a,erp_sc_cltzd_detail b
where 
a.tzdh=b.tzdh and a.shzt='1' and gcbh like :gcbh and clbh like :clbh and tzrq>= :rq1 and  tzrq<= :rq2 
group by gcbh,clbh
)a
group by  gcbh,clbh      消息 170,级别 15,状态 1,第 11 行
      第 11 行: ':' 附近有语法错误。
      消息 170,级别 15,状态 1,第 20 行
      第 20 行: ':' 附近有语法错误。
      消息 170,级别 15,状态 1,第 29 行
      第 29 行: ':' 附近有语法错误。
      消息 170,级别 15,状态 1,第 38 行
      第 38 行: ':' 附近有语法错误。
      消息 170,级别 15,状态 1,第 48 行
      第 48 行: ':' 附近有语法错误。

解决方案 »

  1.   

    sql server 是不支持 like : 的你的  gcbh like :gcbh and clbh like :clbh 
    想表达什么意思
      

  2.   

    :gcbh是你编程语言的传参方式吧?
    SQL的话,你直接把你的:gcbh换成对应的实际数据就可以了。
    如like :gcbh -> like '%' + ':gcbh的值' + '%'
    tzrq>= :rq1 -> tzrq >= ':rq1的值' 注意下类型就可以了
      

  3.   

    like 语法错误 问题
    like 语法 like'%值%' 或  like'值%'或  like'%值' ‘值’的前后可以带 下划线 之类的格式
      

  4.   

    的确不支持like:,,,只是一种格式而已;设置的一个值(变量)
      

  5.   

    like 如果不用 %的话,跟=是没有区别的
      

  6.   

    and gcbh like"'"+ :gcbh +"'"
      

  7.   

    那你要不然把上面的sql语句写到你的PB里面,通过字符串拼接来执行语句。
    要么上面改成存储过程,接受参数,然后把上面的语句封装到存储过程里面去,然后把:gcbh 改成@gcbh的参数形式!!!!!!
      

  8.   

    那你要不然把上面的sql语句写到你的PB里面,通过字符串拼接来执行语句。
    要么上面改成存储过程,接受参数,然后把上面的语句封装到存储过程里面去,然后把:gcbh 改成@gcbh的参数形式!!!!!!
      

  9.   

    sql语句写到你的PB里面,通过字符串拼接来执行语句