Hi,
Please try below query, Let me know if it helps.
declare @rollnumber int
declare @str nvarchar(max)
set @rollnumber =1
set @str= 'SELECT studentname from [Student]
where [id ] in (' + cast(@rollnumber as varchar)+ ')'
exec sp_executesql @str
Thanks,
Hitesh Varde