Posted by: rawbee June 5, 2008
Login in to Rate this Post:
0
?
we can do that several ways...here is one simple idea for getting newid. you can use it as function or can just modify codes to get ur desire result.
DECLARE
@LastID AS VARCHAR(60) --R000001DECLARE
@NewID AS INTSET
@LastID = (SELECT top 1 SequenceID FROM test ORDER BY SUBSTRING(SequenceID,2,60) DESC) -- Gets LastId in ColumnSELECT
@NewID =(LTRIM(MAX(SUBSTRING(SequenceID,2,60)+1))) FROM test -- Gets only Numeric Part and Increment by 1SELECT
REPLACE(@LastID,RIGHT(@LastID,LEN(@NewID)),@NewID)AS NextID -- Replace NewId
Let me know if you have question on my query.