Please refer to:
DECLARE @dummy TABLE(alphanumID VARCHAR(11));
INSERT INTO @dummy VALUES
('0000005692'),('w000005692'),('173031'),('14160525'),('2229301'),('2229301'), ('000H304979'),('w0000005692'),('0000000017'),('0000000002'),('2229301'),('2229301');
;with cte1
as (SELECT*, CAST(CAST(alphanumID AS VARBINARY(4)) AS BIGINT) as numericID
FROM @dummy)
,cte2 as(SELECT*,rank() over(order by alphanumID)rn from cte1)
select alphanumID,cast(numericID as varchar)+cast(rn as varchar) numericID from cte2
If you have any question, please feel free to let me know.
If the response is helpful, please click "Accept Answer" and upvote it.
Regards
Echo
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
Hot issues November--What can I do if my transaction log is full?
Hot issues November--How to convert Profiler trace into a SQL Server table