您的位置:首页 > 数据库

SQL取得最大排序数字并累加1的自定义函数

2004-04-07 22:05 423 查看
/**********************************************************************
函数名:GetMaxSqrt(@SqrtType)
参数:@SqrtType定义取值的表
    @MaxSqrtID:返回max(sqrt)+1
返回 数字
power by adpost
email:zrsz@hotmail.com
**********************************************************************/
CREATE FUNCTION GetMaxSqrt(@SqrtType as int)
RETURNS int
WITH ENCRYPTION
as
BEGIN
 declare @MaxSqrtID as int
 if(@SqrtType=1)
 begin
  select @MaxSqrtID = max(CategorySqrt) from LXBIZ_Category
 end
 if(@SqrtType=2)
 begin
  SELECT @MaxSqrtID = max(SubClassSqrt) FROM LXBIZ_SubClass
 end
 if(@MaxSqrtID is null)
 begin
  select @MaxSqrtID = 0
 end
 return @MaxSqrtID+1
END

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
相关文章推荐