It is not possible for a select statement to assign values to variables and return a resultset in the same SELECT statement - this is a restriction of SQL Server. Wouldn't it be great if it were possible!
Why do you wish to use variables here, if you're requiring a single statement? Would the following not work for you?
WITH cte (tallest, smallest) AS (
SELECT MAX(height), MIN(height) FROM animals
)
SELECT animal_name FROM animals, cte WHERE height BETWEEN smallest AND tallest
If you wish to use the variables later on in a stored procedure, then your only option is to use two select statements: One for the assignment and one for the select:
DECLARE @tallest INT, @smallest INT
SELECT @tallest = MAX(height), @smallest = MIN(height) FROM animals
SELECT animal_name FROM animals WHERE height BETWEEN @smallest AND @tallest
Note that when using ADO, you can use compound queries in an ADO command. In other words, your command component can include more than one statement, so both of the above solutions would work.