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

类别:数据库 点击:0 评论:0 推荐:

/**********************************************************************
函数名:GetMaxSqrt(@SqrtType)
参数:@SqrtType定义取值的表
    @MaxSqrtID:返回max(sqrt)+1
返回 数字
power by adpost
email:[email protected]
**********************************************************************/
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

 

本文地址:http://com.8s8s.com/it/it20926.htm