Posted by: arnzombie June 10, 2008
Login in to Rate this Post:
0
?
Its my pleasure, anyways why dnt you get the highest id number in this case or pass the highest id number as parameter...
alter function NextCustomerNumber
returns char(7)
as
begin
set @id = select max(ID) from table_name ;--to get the highest id number from the table
return 'R' + right('000000' + convert(varchar(10), @id), 6)
end;
----------------------------------------------------------------------------------------------
OR
begin
set @id = select max(ID) from table_name ;--
select NextCustomerNumber(@id) ....
END;