关闭

sql语句

614人阅读 评论(0) 收藏 举报

内部往来:

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 '公司名称','郸%','',''

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:262513次
    • 积分:2991
    • 等级:
    • 排名:第12127名
    • 原创:62篇
    • 转载:53篇
    • 译文:0篇
    • 评论:50条
    最新评论