create procedure sp_test(
@cus_ID char(10),
@Trade_DateTime char(20))
as
begin
declare @s varchar(8000)
set @s='select a.cus_ID,a.cus_NAME,sum(cast(b.Trade_Value as money))
from cus_infor a,trade b where a.cus_ID=b.cus_ID and rtrim(b.Cancel_Flag)=''0'''
if (@cus_ID is not null)
set @s=@s+' and a.cus_ID='''+@cus_ID+''''
if (@Trade_DateTime is not null)
set @s=@s+' and b.Trade_DateTime='''+@Trade_DateTime+''''
set @s=@s+' group by a.cus_ID,a.cus_NAME'
exec(@s)
end
go
@cus_ID char(10),
@Trade_DateTime char(20))
as
begin
declare @s varchar(8000)
set @s='select a.cus_ID,a.cus_NAME,sum(cast(b.Trade_Value as money))
from cus_infor a,trade b where a.cus_ID=b.cus_ID and rtrim(b.Cancel_Flag)=''0'''
if (@cus_ID is not null)
set @s=@s+' and a.cus_ID='''+@cus_ID+''''
if (@Trade_DateTime is not null)
set @s=@s+' and b.Trade_DateTime='''+@Trade_DateTime+''''
set @s=@s+' group by a.cus_ID,a.cus_NAME'
exec(@s)
end
go
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货