Apurva Singh

Apurva Singh

  • NA
  • 268
  • 56.5k

retrive data from stored procedure

Jul 13 2018 12:27 AM
I have two table , now i want to two or more column from second table  in store procedure.
 
 
when i add column name  in stored procedure then i am getting error.
 
i am providing my stored procedure, please help 
 
CREATE PROCEDURE sp_Productlist --'1' ,'10','1'
@PageIndex INT = 1
,@PageSize INT = 10
,@PageCount INT OUTPUT
AS
BEGIN
SET NOCOUNT ON;
SELECT ROW_NUMBER() OVER
(
ORDER BY Pro_id ASC
)AS RowNumber,
Product_Master.Pro_id,
Product_Master.Pro_Name,
Product_Master.Pro_MRP,
Product_Master.Pro_Description,
Product_Master.Pro_Discount,
(select top(1) product_pic.Pro_Pic_Url
from product_pic       Here i want to get more column from table product_pic
where product_pic.Pro_id=Product_Master.Pro_id)
as Image
INTO #Results
FROM Product_Master
DECLARE @RecordCount INT
SELECT @RecordCount = COUNT(*) FROM #Results
SET @PageCount = CEILING(CAST(@RecordCount AS DECIMAL(10, 2)) / CAST(@PageSize AS DECIMAL(10, 2)))
PRINT @PageCount
SELECT * FROM #Results
WHERE RowNumber BETWEEN(@PageIndex -1) * @PageSize + 1 AND(((@PageIndex -1) * @PageSize + 1) + @PageSize) - 1
DROP TABLE #Results
END
 

Answers (3)