 Hello guys welcome back my name is Sushil Singh and this is continuation of SQL Server interview questions and answers. So today I am going to discuss one more question which is related to interviews. So in this question you will understand add only integer values from any string. So this is our question you have a variable and in this variable you have some string values like you can see here this is our input and we want to add only numeric field in our output. So we can add 1 then 3 then 4 8 9 and 1 and you will see you will return 26 as an output. So let's move to SQL Server Management Studio where you will understand how we can do this. So here I have declared four variables variable 1 which is wire card type and second is at the rate length 1 and then final and last variable is at the rate t. So in the first variable at the rate where 1 I have in a slice the input string which is at the rate at the rate 1 has something like that and then I am going to calculate the length of this input string. So it will return the length by using length function and I am going to in a slice in at the rate length 1 variable. So here I am going to use a loop by which this loop will not be and until the value of this at the rate length 1 variable is greater than 0. Once value of this is equals to 0 then this loop will be and. So here you can see I am going to pick the first value from left hand side from our input string. So it's at the rate so here I am going to pick this at the rate by using left function and it will in a slice in at the rate t variable and then I am going to check this is numeric or not. If value of this is numeric then I am going to execute this begin and end. Otherwise it will go to our second condition which is set at the rate where 1 is equals to it's going to pick the value from right hand side after skipping this first letter by which we will get at the rate 1 has 3 in our at the rate where 1 variable here. Then I am going to set at the rate 1 minus 1. So here you can see this loop will go once more and next time it will pick second at the rate and it will executed as it is and third time once value will pick by 1 then our if condition will be satisfied then it will go inside and here I am going to add in this final variable by this at the rate t variable. So finally it will add 1 once it will reach 3 then our if condition will be satisfied and it will add 3 on our 1. So value for at the rate final variable after 3 is 4. So this loop will be executed until this string will not be completed and at last you will get the result and the result output would be 26 as I have discussed discussed at starting so it's 26. So I hope you have understand how you can achieve this output by using loop. So thank you so much for watching this video. If you like this video please subscribe our channel for many more videos. If you need this script it will available on my Facebook page. If you need you can copy from there. Thank you so much.