Hi,
try this,
declare @product1 CURSOR
declare @ID int
declare @cnt int;
set @cnt = 0;
SET @product1 = CURSOR for SELECT Id from Tbl_StkDetailedBookStock where IsActive='True'
and BookStockId=@tempd4 ;
open @product1
fetch next from @product into @ID
while(@@fetch_status=0)
begin
set @cnt=@cnt+1
fetch next from @product into @ID
end
close @product1
deallocate @product1
select @cnt
hope it will help....
Happy coding.. :)