当前位置:主页>销售管理软件> 列表

CREATE FUNCTION my_fid 如何返回一

销售管理软件版1楼: CREATE FUNCTION my_fid
RETURNS bigint
AS
BEGIN
DECLARE @max_fid bigint
set @max_fid= ((select max(fid) from t_base).fields[0].asinteger)
return @max_fid
END

返回一个表的一个字段的最大值
这个函数怎么写 我写的不对

2楼: 建议使用存储过程,sql2000通过:
drop procedure my_fid
go

CREATE procedure my_fid @max_fid float output
AS
BEGIN
select @max_fid=max(jxvalue) from acsrecord where not (jxvalue is null)
END

--调用
declare @a float
execute my_fid @a output
print @a 如万能档案管理软件

3楼: 谢谢 ahhlian,
但是如果我想用函数写 该怎么写呢
我正在研究

4楼: 你这函数是在哪里创建的啊?delphi中还是sql中?

5楼: CREATE FUNCTION my_fid
RETURNS bigint
AS
BEGIN
DECLARE @max_fid bigint
set @max_fid= cast((select max(fid) from t_base) as integer)
return @max_fid
END

6楼: 特别感谢 ahhlian


我还不知道 select @max_fid=max(jxvalue)
有这种写法 按照你的写法 我知道我编的函数错哪了
我是这么写的 我成功了
CREATE FUNCTION F_max_fid()
RETURNS bigint
AS
BEGIN
DECLARE @max_fid bigint
select @max_fid=max(fid) from t_base
where not (fid is null)
SET @max_fid=@max_fid+1
return @max_fid
END

也十分感谢yl19840614
你的方法我正在看

销售管理软件版7楼: 多人接受答案了。