|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Wednesday, March 27, 2013 3:34 AM
Points: 165,
Visits: 405
|
|
|
|
|
|
Mr or Mrs. 500
      
Group: General Forum Members
Last Login: Saturday, June 08, 2013 11:16 PM
Points: 513,
Visits: 149
|
|
DECLARE @D DECIMAL(18,9) ,@S VARCHAR(20) ,@R VARCHAR(20) ,@Pos SMALLINT
SET @D = 5.1235698 SET @S = CAST(@D AS VARCHAR(20)) SET @R = REVERSE(SUBSTRING(@S, CHARINDEX('.', @S) + 1, 20)) SET @Pos = PATINDEX('%[1-9]%' , @R) IF @Pos = 0 SELECT 0 ELSE SELECT LEN(SUBSTRING(@R, @Pos, 20)) AS Length
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: Wednesday, March 27, 2013 3:34 AM
Points: 165,
Visits: 405
|
|
That is true.. your script evaluates in the same way as mine does. As noted, there exists many approaches that includes yours.
However, the SUBSTRING function along with CHARINDEX seems costlier than the PARSENAME...
Neverthless, thanks for adding this code piece :)
--In 'thoughts'... Lonely Rogue
|
|
|
|