declare id_cursor CURSOR
for select quesNo from answer
open id_cursor
declare @value1 varchar(100)
fetch next from id_cursor into @value1 while (@@fetch_status<>-1)
begin
if(@@fetch_status<>-2)
begin
select * from ques where quesNo=@value1
end
fetch next from id_cursor into @value1
end
close id_cursor
deallocate id_cursor