CREATE PROCEDURE softwareset @soft_name varchar(50), @type_code varchar(1), @result varchar(1) output AS declare @maxcode varchar(4) declare @code varchar(1) declare @max char(3) declare @soft_code char(4) select @code=@type_code if not exists(select * from software where soft_name=@soft_name and type_code=@code) begin if not exists(select * from software where type_code=@code) select @soft_code=@code+'001' else begin select @maxcode=max(soft_code) from software where type_code=@code select @max=right(rtrim(@maxcode),3)+1 select @soft_code= case len(@max) when 1 then @code+'00'+@max when 2 then @code+'0'+@max when 3 then @code+'0'+@max else @code+@max end end insert software(soft_code,type_code,soft_name) values(@soft_code,@type_code,@soft_name) select @result='0' end else select @result='1'
CREATE PROCEDURE [P_sum_day_money] @day_date int, @month_date int, @year_date int, @gz_money float output, ---@xj_money float output, @x_type char, @check int AS if @check=1select @gz_money=sum(x_je) from t_xf where x_type=@x_type and year(x_date)=@year_date and month(x_date)=@month_date and day(x_date)=@day_date if @check=2select @gz_money=sum(x_je) from t_xf where x_type=@x_type and year(x_date)=@year_date and month(x_date)=@month_date
if @check=3select @gz_money=sum(x_je) from t_xf where x_type=@x_type and year(x_date)=@year_date GO一个例子 不过返回的是浮点型的 你定义的时候定义 varchar() 应该可以的 希望有帮助
@soft_name varchar(50),
@type_code varchar(1),
@result varchar(1) output
AS
declare @maxcode varchar(4)
declare @code varchar(1)
declare @max char(3)
declare @soft_code char(4)
select @code=@type_code
if not exists(select * from software where soft_name=@soft_name and type_code=@code)
begin
if not exists(select * from software where type_code=@code)
select @soft_code=@code+'001'
else
begin
select @maxcode=max(soft_code) from software where type_code=@code
select @max=right(rtrim(@maxcode),3)+1
select @soft_code= case len(@max)
when 1 then @code+'00'+@max
when 2 then @code+'0'+@max
when 3 then @code+'0'+@max
else @code+@max
end
end
insert software(soft_code,type_code,soft_name) values(@soft_code,@type_code,@soft_name)
select @result='0'
end
else
select @result='1'
@day_date int,
@month_date int,
@year_date int,
@gz_money float output,
---@xj_money float output,
@x_type char,
@check int
AS
if @check=1select @gz_money=sum(x_je) from t_xf where x_type=@x_type
and year(x_date)=@year_date
and month(x_date)=@month_date
and day(x_date)=@day_date
if @check=2select @gz_money=sum(x_je) from t_xf where x_type=@x_type
and year(x_date)=@year_date
and month(x_date)=@month_date
if @check=3select @gz_money=sum(x_je) from t_xf where x_type=@x_type
and year(x_date)=@year_date
GO一个例子 不过返回的是浮点型的 你定义的时候定义 varchar() 应该可以的
希望有帮助