Answer: Yes. We can alter the flow of the execution of the statements using "GOTO" and "Lable name"
Using GOTO statement, we can skip the flow of the execution pointing to Label name.
Declare @Input Int, @Status Varchar(5), @Result Varchar(100)
Select @Input = 10
Select @Result = 'The Input(' + Cast(@Input as varchar(5)) + ') is '
If ((@Input%2) = 0)
Goto Even
Else
Goto Odd
Even:
Select @Status = '"Even"'
Goto Result
Odd:
Select @Status = '"Odd"'
Goto Result
Select @Status = '.....Test.....'
Result:
Select @Result = @Result + @Status
Select @Result
Goto Finish
Finish:
Asked In: Many Interviews |
Alert Moderator