0
Reply

i want to check which is greater value get

Nirmal KumarC

Nirmal KumarC

Oct 3 2014 9:51 AM
584
i want my query two values get table different id with same date,so i want this two value which one greater than record


select    @EID = count(ltrim(rtrim(ltrim(isnull(BI.EID,'')))))  from BATCHID BI,CO_BATCH_MASTER CBM  where bi.BID = CBM.cbm_batch_id and bi.B_ACTIV<>'D' and CBM.cbm_active<>'D' 
and cbm.cbm_batch_start_dt < @cbm_batch_start_dt and CBM.cmn_minor_code=@cmn_minor_code 

while loop or if condition using this id get above Query codewise more than one time this batchid came means i will get Below two values .

BatchID:
ARPA/B147
ARPA/B148 

after this two values below code wise separate only integer value get 147,148 this two value which one greater.

Example:

above Query get @EID value.
Declare @strAlphaNumeric varchar (50) 
Declare @intAlpha INT  
 SET @strAlphaNumeric=@EID 


SET @intAlpha = PATINDEX('%[0-9]%', @strAlphaNumeric)
select Cast(SUBSTRING(@strAlphaNumeric,@intAlpha, len(@strAlphaNumeric)) as int)
select SUBSTRING(@strAlphaNumeric,1,@intAlpha-1)

This code get it ARPA/B147 this value after loop is running ARPA/B148 this value get but different date 

Running the above code shows output as follows


147
148


ARPA/B
ARPA/B


 thanks