sqlServer 函数

sqlServer 函数

 

ALTER FUNCTION [dbo].[IM_fn_SRNO](@reg VARCHAR(64),@inv VARCHAR(64))
RETURNS [varchar](256) WITH EXECUTE AS CALLER
AS
begin
declare @Name varchar(256)
declare @regNew varchar(256)
select @Name =rnum from (  select row_number() over(ORDER BY INVOICECODE) as rnum ,  INVOICECODE  
from  CM_FAREDETAIL  where regcode = @reg group by INVOICECODE  )  t where t.INVOICECODE =@inv

if @name >1
BEGIN
  set @regNew = @reg +‘00‘ + @name
END
ELSE
BEGIN
    set @regNew = @reg
END

    return @regNew
    END

sqlServer 函数

上一篇:Flink基础(130):FLINK-SQL语法 (24) DQL(16) OPERATIONS(13)ORDER BY clause/LIMIT clause


下一篇:mysql 中 find_in_set使用方法(细节)