We can try to get max age simply by using 

```
SELECT TOP 1 age FROM Head1 ORDER BY Age DESC

```

But I've tried using while loop in SQL Server

**code**

```
declare @a int, @m int, @maxo int;
set @maxo = 0;
while(@a<10)
begin
    select name, @m = age from head1 where ID = @a;
    if @m>@maxo
       @maxo = @m;
    set @a=@a+1;
end
print @maxo

```

**error**

> 
> Msg 141, Level 15, State 1, Line 5  
> 
>  A SELECT statement that assigns a value to a variable must not be combined with data-retrieval operations.
> 
> 
> Msg 102, Level 15, State 1, Line 7  
> 
>  Incorrect syntax near '@maxo'.
> 
> 
> 

I am sort of stuck here. Please help guys.....