Question: On a table, there's a delete trigger that performs some operations and then at the end, executes a select statement, so when you do something like...

```
delete from mytable where id=1

```

it returns a recordset.

Is there a way to save the results of that recordset into a temp table or something? I tried something like this:

```
declare @temptable table (returnvalue int);
insert into @temptable (returnvalue)
delete from mytable where id=1;

```

But apparently that syntax doesn't work.

Answer: 
You are amost there. *And I am not challenging or judging this approach, just providing the answer.* There is [a working example](http://plnkr.co/edit/DNas7u8e8NuJMP2n0RUe?p=preview) .

You've properly created new scope. Very good. But that is just an **A**. The essential and curcial **B** is missing. **B** - is opposite to **A** `===` destroy new scope *(once old)*.

This will do the job for us:

```
 app.controller('MenuController', ["$scope","$compile", "$state","$http",
    function MenuController($scope,$compile, $state, $http) {
        $scope.goToUrl = function (view) {

                // was scope previously created
                var hasPreviousChildScope = this.childScope !== void 0
                                         && this.childScope !== null;

                if(hasPreviousChildScope)
                {
                  // we must clear after ourselves
                  this.childScope.$destroy();
                  this.childScope = null;
                }

                // create new scope
                this.childScope = $scope.$new();

                var html;
                var state;
                if(view == 'Alerts'){
                  view = '<div ui-view="Alerts"></div>';
                  state  = 'appHome'
                }
                else{
                  view = '<div ui-view="Other"></div>';
                  state  = 'appOther'
                }
                $('#test').html($compile(view)(this.childScope));
                $state.go(state);

        };
    }
]);

```

Check that all [in action here](http://plnkr.co/edit/DNas7u8e8NuJMP2n0RUe?p=preview)
Why do you make it so complicated? Is there a special reason why you are using

```
if(view == 'Alerts'){
   view = '<div ui-view="Alerts"></div>';
   state  = 'appHome'
}
else{
   view = '<div ui-view="Other"></div>';
   state  = 'appOther'
   }

$('#test').html($compile(view)(scope));
$state.go(state);

```

Isn't it possible to use something like

```
<div ng-controller="MenuController">
   <button ui-sref="appHome" value="CLick Me">GoTo Alerts</button>
   <button ui-sref="appOther" value="CLick Me">GoTo Other</button>
</div>
<section ui-view></section>

```

I used ui-sref to easily navigate between states. I have prepared a little demo to illustrate that. Have a look [here](http://plnkr.co/edit/OLNuV55a9K8uqKNWO5Sc?p=preview).
Does that help? Is it usable? That way you don't even need the menuController.

If you need named views (multiple nested views) have a look at the [documentation](https://github.com/angular-ui/ui-router/wiki/Multiple-Named-Views). Is is explained pretty well. You would end up with something like:

```
<!-- index.html -->
<body>
  <div ui-view="alerts"></div>
  <div ui-view="other"></div>
</body>

$stateProvider
  .state('report', {
    views: {
      'alerts': { ... templates and/or controllers ... },
      'other': {},
    }
  })

```