In this example we will write how to print twisted word in sql. You can change the word written by changing @sentence variable’s value. In this example we used while loop and replicate function. You can change @j and @a variable’s values to see diffrent twisted words.
1 2 3 4 5 6 7 8 9 10 11 12 13 |
Declare @i int,@j int,@a int ,@sentence varchar(40) Set @sentence = 'queryexamples.com' Set @i = 1 SEt @j = 3 Set @a = 3 while(@i<=len(@sentence)) Begin Print Space(@a-abs(@j))+Substring(@sentence,@i,1) Set @j = @j -1 if (abs(@j)>@a) Set @j = @a-1 Set @i = @i + 1 End |
Result of Code