Hi @coool sweet ,
Viorel-1's method looks great. I modified it into a function, which is more convenient to use, please refer to:
CREATE TABLE #test(string varchar(25))
INSERT INTO #test VALUES('123432453212'),('1dddddddddd'),('1gh45j2dungj')
create function [dbo].[Getsum](@UDF02 varchar(40)) returns int
declare @string varchar(max)
set @string =@UDF02
declare @sum int = 0
declare @i int = len(@string)
while @i > 0
set @sum += isnull(try_cast(substring(@string, @i, 1) as int), 0)
set @i -= 1
DROP FUNCTION [dbo].[Getsum]
This answer should have appeared in the comment, but due to the character limitation of the comment, it appears here.
If you have any question, please feel free to let me know.
If the answer is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.
@coool sweet ,
Did you have a chance to try the proposed solutions?
Could you please validate all the answers so far and provide any update?
If all of them are not working or helpful, please provide more sample data or details about your issue.