Try this,
ALTER procedure [dbo].[recursive]
(
@id int =null,
@studentname varchar(20) =null
)
As
BEGIN
if(@studentname is not null and @id is null)
Begin
select * from productsearch where studentname =@studentname
end
else if(@studentname is null and @id is not null)
Begin
select * from productsearch where id =@id
end
end
Remove
the below from your stored procedure.
with ProductSearch
As
(
select * from student
)
select * from ProductSearch