sql语句

内部往来:

alter proc sp_report1
@f1 varchar(20),
@f2 varchar(20),
@p varchar(20),
@v1 varchar(50),
@v2 varchar(50)
with encryption
as
begin
declare @s varchar(500)
select @s='select * from t_nbwl2006 a where 1=1'
if isnull(@p,'')='' and isnull(@f1,'')='' and isnull(@f2,'')=''
select @s=@s+' and 科目代码 like ''1132%'''
if isnull(@p,'')<>''
select @s=@s+' and rtrim(年度)+rtrim(期间)='''+replace(replace(''+@p+'','年',''),'期','')+''''
if isnull(@f1,'')<>''
select @s=@s+' and '+@f1+' like ''%'+@v1+''''
if isnull(@f2,'')<>''
select @s=@s+' and '+@f2+' like ''%'+@v2+''''
--print @s
select @s=@s+'and 时间戳 in (select max(时间戳) from t_nbwl2006 where 科目代码=a.科目代码)'
exec(@s)
end

exec sp_report1 '','','','',''

固定资产:

alter proc sp_report2
@gsmc varchar(100),
@v varchar(100),
@qj varchar(100),
@timestamp varchar(100)
with encryption
as
begin
declare @s varchar(3000)
select @s='select * from v_gdzc where 1=1 '
if isnull(@gsmc,'')='' and isnull(@qj,'')='' and  isnull(@timestamp,'')=''
select @s=@s+' and 时间戳=(select max(时间戳) from gdzc) and 期间=(select max(期间) from v_gdzc)'
if isnull(@gsmc,'')<>''
select @s=@s+' and '+@gsmc+' like ''%'+@v+''''
if isnull(@qj,'')<>''
select @s=@s+' and 期间='''+@qj+''''
if isnull(@timestamp,'')<>''
select @s=@s+' and 时间戳 like ''%'+@timestamp+''''
print @s
exec(@s)
end

exec sp_report2 '公司名称','郸%','',''

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值