Recent PostsRecent Posts Popular TopicsPopular Topics
 Home Search Members Calendar Who's On

 Script to calculate Precision & Scale of a Decimal Value Rate Topic Display Mode Topic Options
Author
 Message
 Posted Tuesday, June 5, 2012 1:14 PM
 SSC-Enthusiastic Group: General Forum Members Last Login: Monday, November 14, 2016 7:08 PM Points: 173, Visits: 436
 Comments posted to this topic are about the item Script to calculate Precision & Scale of a Decimal Value --In 'thoughts'...Lonely Rogue
Post #1311438
 Posted Tuesday, June 19, 2012 6:54 AM
 Right there with Babe Group: General Forum Members Last Login: Monday, March 23, 2015 4:37 AM Points: 773, Visits: 310
 DECLARE @D DECIMAL(18,9) ,@S VARCHAR(20) ,@R VARCHAR(20) ,@Pos SMALLINTSET @D = 5.1235698SET @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 0ELSE SELECT LEN(SUBSTRING(@R, @Pos, 20)) AS Length
Post #1317973
 Posted Friday, June 22, 2012 10:35 AM
 SSC-Enthusiastic Group: General Forum Members Last Login: Monday, November 14, 2016 7:08 PM Points: 173, Visits: 436
 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
Post #1320101
 Posted Tuesday, May 10, 2016 9:30 AM
 SSCrazy Eights Group: General Forum Members Last Login: Today @ 7:49 AM Points: 8,308, Visits: 854
 Thanks for the script.
Post #1784821

 Permissions