you do not seem to think about your problems at all. you wanted the counter to start a 1 for each year. this means you need a separate counter for each year. but you do pass the year to the sp. also you never update the counter in the database, so the same value is always return. you also must think about race conditions (two calls at the same time).
as simple table:
create table yearcounter
(
year int not null unique,
counter int not null
)
as simple proc to return the current counter
create procedure getcount
@year int
as
merge yearcounter as target
using (select @year as year) as source
on source.year = target.year
when not matched by target then
insert (year, counter)
values (source.year, 1)
when matched then update
set target.counter = target.counter + 1
output inserted.*;
sample call:
exec getcount 2022
year counter
2022 1