BatchID generation in SQL Server

Bandi
Posted by Bandi under Sql Server category on | Points: 40 | Views : 420
declare @tab table( BatchCode varchar(100))
insert into @tab
SELECT 'PSF/180' union all
SELECT 'PSF/B180' union all
SELECT 'ERS/B366' union all
SELECT 'ARPA/B146' union all
SELECT 'EFA/B989' union all
SELECT 'PSSR/B1096' union all
SELECT 'RECP/B175' union all
SELECT 'CHEMCO/B73' union all
SELECT 'ERS/B367'

select BatchCode
,LEFT(Batchcode, patindex('%[0-9]%',BatchCode)-1)+ CAST(cast(SUBSTRING(BatchCode, patindex('%[0-9]%',BatchCode), len( BatchCode)) as int) +1 as varchar(50)) NextBatchSeries
from @tab

Comments or Responses

Posted by: vishalneeraj-24503 on: 9/19/2014 Level:Platinum | Status: [Member] [MVP] | Points: 10
Hi Bandi,

Where can we use your code and what is the use of generating the Batch Id.
Can you please elaborate?So that we can use.

Login to post response