 Hello, welcome to SSUnitech. So, see this side and this is continuation of SQL Server interview questions and answers. So, today we are going to discuss one more interview question and this question was asked in Genpak interview where one of my friend has attended the interview with the Genpak. So, that question was asked with my friend. So, let's move to next slide to understand about the question. So, as we can see we have an input string and that string is available in a variable. So, we want to split that string with the characters like SSUnitech. So, we want to divide this in one column and each character will move to next row. So, how we can write the query for getting this output. So, let's move to SQL Server Management Studio where we will write the query for getting this output. So, as I am using SQL 2017 you may have another version of SQL Server. So, here first of all I would like to declare a variable that will contain the input string. Data type is worker and that is 50 and we want to set the value for this is SSUnitech as we seen in the slide. Next, we just want to declare a variable and that would be going to start from 1 declare at the rate i and this is integer and initial value is 1. Next, we want to declare one more variable that would contain the total length of the string. So, we can say as length and this is integer. Here we want to set the value which is the input string. So, this is the length and what would be the length of this at the rate str. So, this is the input string length. Next, we need to declare a table type variable. So, we can say at table that would contain the output values and it would have only one column that is value and that should be worker type and it should be going to contain only one character in each row. So, this is the initial setup for our query. Next, we need to use a loop. So, we can write the while loop then at the rate length if length value is greater than 0 then we want to execute this loop and inside this loop what we need to do. So, first we want to insert the value into this table type variable and then we want to select the value. In the selection of this value, we can use the substring function. So, what would be the substring function? Here we need to specify the expression. So, we want to get the value from this at the rate str then starting position. So, starting position would be 1 that is at the rate i then how many characters we want? So, we want only one character for each time then close the bracket. So, it will be going to get the values. Next, we need to increase the value for i then i should be equals to at the rate i plus 1 and we need to decrease the value for at the rate length. So, this length should be equals to at the rate length minus 1. After this loop, we can select this table. So, we can write select str from at the rate table. So, if we will execute this query, we will get the output. So, let me execute the query and check the output. So, as we can see we are getting ss then we have space that is fine then unit it. So, we are getting the output as we were expected. So, thank you so much for watching this video. If you like this video, please subscribe our channel to get many more videos. Don't forget to press the bell icon to get the notification of our newly uploaded videos. Thank you so much for watching.