try this
You have to set value for @schoolId from the select query. You cant set it separately.
Incorrect:
select School_id from School where School_name=@schoolname;
set @schooid=School_id;
Correct one:
select @schooid=School_id from School where School_name=@schoolname
create procedure sp_branchinsert(@branchid int,@schoolname varchar(100),@branchname varchar(50),@createddateandtime datetime)
as
begin
declare @schooid int
select @schooid=School_id from School where School_name=@schoolname
insert into Branch(Branch_id,School_id,Branch_name,Created_date_time)values(@branchid,@schooid,@branchname,@createddateandtime)
end