34,871
社区成员
发帖
与我相关
我的任务
分享create table targetid(id bigint)
insert targetid select 2007010102
union all select 2007031503
union all select 2007061204
union all select 2007080505
union all select 2007080625
go
create procedure sp_Test
as
begin
declare @n bigint
select @n=max(id)+1 from targetid
select cast(stuff(rtrim(@n),1,8,replace(convert(varchar(10),getdate(),120),'-','')) as bigint)
end
go
exec sp_Test
/*
--------------------
2008011026
(1 row(s) affected)
*/
drop procedure sp_Test
drop table targetid