其中and czbt2.hnxc.czbt_btdj.lxdm in('0501','0502','0503')和
and month(djrq)=3
两个条件为不确定条件是指可以为:czbt2.hnxc.czbt_btdj.lxdm in('0541','0542','0513')
and month(djrq)=11
and month(djrq)=3
两个条件为不确定条件是指可以为:czbt2.hnxc.czbt_btdj.lxdm in('0541','0542','0513')
and month(djrq)=11
@lxdm varchar(40),
@month int
as
begin
declare @sql varchar(8000)
set @sql='select cast(yhzh as char(20))+cast(object_name as char(10))+cast(gh as char(10))+cast(1 as char(10))+cast(idcard_num as char(20))+cast(sum(btje) as char(16))+' '
from czbt2.hnxc.czbt_btdj,t_sn_object,t_sn_object_zhxx
where t_sn_object.id=t_sn_object_zhxx.btdx_uid
and t_sn_object.id=czbt2.hnxc.czbt_btdj.btdx_uid
and czbt2.hnxc.czbt_btdj.lxdm in('+@lxdm+')
and month(djrq)='+rtrim(@month)+'
group by yhzh,object_name,gh,idcard_num
order by gh' exec(@sql)
end
goexec sp_test '''0501'',''0502'',''0503''',3
exec sp_test '''0541'',''0542'',''0513''',11
go
@lxdm varchar(40),
@month int
as
begin
declare @sql varchar(8000)
set @sql='select cast(yhzh as char(20))+cast(object_name as char(10))+cast(gh as char(10))+cast(1 as char(10))+cast(idcard_num as char(20))+cast(sum(btje) as char(16))+'' ''
from czbt2.hnxc.czbt_btdj,t_sn_object,t_sn_object_zhxx
where t_sn_object.id=t_sn_object_zhxx.btdx_uid
and t_sn_object.id=czbt2.hnxc.czbt_btdj.btdx_uid
and czbt2.hnxc.czbt_btdj.lxdm in('+@lxdm+')
and month(djrq)='+rtrim(@month)+'
group by yhzh,object_name,gh,idcard_num
order by gh' exec(@sql)
end
goexec sp_test '''0501'',''0502'',''0503''',3
exec sp_test '''0541'',''0542'',''0513''',11
go
asselect cast(yhzh as char(20))+cast(object_name as char(10))+cast(gh as char(10))+cast(1 as char(10))+cast(idcard_num as char(20))+cast(sum(btje) as char(16))+' '
from czbt2.hnxc.czbt_btdj,t_sn_object,t_sn_object_zhxx
where t_sn_object.id=t_sn_object_zhxx.btdx_uid
and t_sn_object.id=czbt2.hnxc.czbt_btdj.btdx_uid
and charindex(','+czbt2.hnxc.czbt_btdj.lxdm+',',','+@lxdm+',')>0
and month(djrq)=@month
group by yhzh,object_name,gh,idcard_num
order by gh
from tba,tbb,tbc
where tba.id=tbb.uid
and tba.id=tbc.uid
and tbc.lxdm in('0501','0502','0503')
and month(djrq)=3
group by zh,name,gh,sfz
order by gh
As
Begin
select cast(yhzh as char(20))+cast(object_name as char(10))+cast(gh as char(10))+cast(1 as char(10))+cast(idcard_num as char(20))+cast(sum(btje) as char(16))+' '
from czbt2.hnxc.czbt_btdj,t_sn_object,t_sn_object_zhxx
where t_sn_object.id=t_sn_object_zhxx.btdx_uid
and t_sn_object.id=czbt2.hnxc.czbt_btdj.btdx_uid
and CharIndex(czbt2.hnxc.czbt_btdj.lxdm, @lxdm) > 0
and month(djrq)=@djrq
group by yhzh,object_name,gh,idcard_num
order by gh
End
from czbt2.hnxc.czbt_btdj,t_sn_object,t_sn_object_zhxx
where t_sn_object.id=t_sn_object_zhxx.btdx_uid
and t_sn 附近为语法错误
exec '0541,0542,0513' ,3
以上偶的存储过程调用方法
exec '0541,0542,0513' ,3
--------------:),掉了存儲過程名稱.
roy_88的這麼調用 EXEC test_p '0541,0542,0513' ,3
谢谢roy_88(中国风_燃烧你的激情!!!) 能否将结果导出为一个文本文件?