If you want the values to be stored in separate variables (Your query returns only one matching row)
You can do like following
DECLARE @ID INT
DECLARE @Name VARCHAR(100)
DECLARE @School VARCHAR(100)
SELECT TOP 1 @ID=Id,@Name=Name,@School=School FROM tblSchool WHERE Id=2
SQL Server also supports table type variables, for your case you can create a table type as following.
CREATE TYPE [dbo].[MyVairable] AS TABLE(
Id INT NOT NULL,
Name VARCHAR(100) NULL,
School VARCHAR(100)
)
Declare the variable as following.
DECLARE @MyVariable [dbo].[MyVairable]
To select the rows into your variable.
INSERT INTO @MyVariable
SELECT Id,Name,School FROM tblSchool WHERE Id=2