SHARE
TWEET

Untitled

Piexplode Mar 21st, 2019 (edited) 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE FUNCTION def.Digits (@FunctionInput INT)
  2. RETURNS INTEGER
  3. AS
  4. BEGIN
  5. DECLARE @Dropoff VARCHAR(MAX) = CAST(@FunctionInput AS VARCHAR(MAX))
  6. DECLARE @Final VARCHAR(MAX) = @Dropoff
  7. DECLARE @DropIncrement INT = 1
  8. DECLARE @StepIncrement INT = 0
  9. WHILE LEN(@Final) <> 1
  10. BEGIN
  11. SET @DropIncrement = 1
  12.  
  13. WHILE LEN(@Dropoff) <> 0
  14. BEGIN
  15. SET @DropIncrement = @DropIncrement * LEFT(@Dropoff,1)
  16. SET @Dropoff = LTRIM(@Dropoff,1)
  17. END
  18.  
  19. SET @Final = CAST(@DropIncrement AS VARCHAR(MAX))
  20. SET @Dropoff = @Final
  21. SET @StepIncrement = @StepIncrement + 1
  22.  
  23. END
  24. RETURN (@StepIncrement)
  25. END
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top