Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 How to return multiple rows from SP?

Author  Topic 

AskSQLTeam
Ask SQLTeam Question

0 Posts

Posted - 2003-08-20 : 07:53:30
Lakshmi writes "Hi,
Can anyone give me a solution to, how to return multiple rows from Stored procedure to asp.net application?
here is my query that would return multiple rows.... I want to create a SP for the query

SELECT Item_Name, Unit_Sold
FROM Item
WHERE (Unit_Sold >=
(SELECT MAX(unit_sold)
FROM item i
WHERE i.cat_id = item.cat_id
GROUP BY (i.cat_id))) AND (Cat_Id <> 103)

Thanks,
-Lakshmi"

dsdeming

479 Posts

Posted - 2003-08-20 : 08:30:32
All you need to do is:

CREATE PROCEDURE whatever
AS
SELECT Item_Name, Unit_Sold
FROM Item
WHERE (Unit_Sold >=
(SELECT MAX(unit_sold)
FROM item i
WHERE i.cat_id = item.cat_id
GROUP BY (i.cat_id))) AND (Cat_Id <> 103)
GO

You may want to replace the 103 with @Cat_id in case that value might change. In that case, make @Cat_id an input parameter of the procedure.

Dennis
Go to Top of Page
   

- Advertisement -