Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Old Forums
 CLOSED - General SQL Server
 Parsing a string to set up for a cast

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2002-07-30 : 09:37:10
Michael writes "I am attempting to take a string value like '8.00.384' which can be variable length in the number of periods and number of characters in each section (before, between, and after the periods) and capture the last characters before the period, in this case the '384' so that I can cast the string as an integer and compare it to another numeric value. How can this be done efficiently?"

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-07-30 : 09:41:51

declare @string varchar(10)
select @string = '8.00.384'
select reverse(left(reverse(@string),charindex('.',reverse(@string))-1))

 


Jay White
{0}
Go to Top of Page
   

- Advertisement -