drop proc GetRCId
go
create proc GetRCId(@int int)
as
begin
declare @next int
declare @id varchar(50)
declare @date varchar(50)
set @int=@int+1
set @date = Convert(varchar(50),getdate(),112)
set @next = 10000+@int
set @id = substring(cast(@next as varchar(5)),len(cast(@next as varchar(5)))-3,4)
set @id ='rc'+@date+@id
print @id
end
go
exec GetRCID 3