1
Answer

from my code i want to check which is greater

Nirmal KumarC

Nirmal KumarC

10y
641
1

  Declare @strAlphaNumeric varchar (50) = 'ARPA/B147 ' 
Declare @strAlphaNumeric1 varchar (50) = 'ARPA/B146 ' 

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

select SUBSTRING(@strAlphaNumeric,1,@intAlpha-1)
select SUBSTRING(@strAlphaNumeric1,1,@intAlpha-1)


Running the above code shows output as follows

147
146

ARPA/B
ARPA/B



I want to check 147 or 146 which is greater.

From the above 147  is greater.

for getting a output 147.

from my above code what changes i have to made to get 147 output.






Answers (1)