TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nirmal KumarC
1.4k
327
79.1k
from my code i want to check which is greater
Oct 3 2014 6:44 AM
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.
Reply
Answers (
1
)
sql server commands
i want to check which is greater value get