I am having a recursive loop of a stored procedure and i want to stop the execution of that recursive loop on a validation and return an empty table.
How can i do that?

This is some sample code :

```
alter procedure Searching
(parameters)
begin
  do something
  if(validation)
     --exit here
  else
    exec Searching(parameters);
end

```

and i have another question of how to declare a global variable in sql? which should not lose it's scope from one stored procedure to another.