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
 General SQL Server Forums
 New to SQL Server Programming
 Stored procedure needs to return all manufacturer_

Author  Topic 

madhan
Yak Posting Veteran

59 Posts

Posted - 2014-09-25 : 15:25:36
[code]
ALTER PROCEDURE [dbo].[getFavoriteList]
@customer_id int,
@manufacturer_name varchar(200) OUTPUT
as
begin

SET NOCOUNT ON

select @manufacturer_name= manufacturer_name from dbo.Favorite_list
return
end
[/code]

Executing this procedure as

declare @catname varchar(200);
execute getFavoriteList 87381, @manufacturer_name= @catname OUT;

select @catname

It returns only one manufacturer name. in the table I have 4 names that all needs to be returned,
please help


tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-09-25 : 15:29:44
ALTER PROCEDURE [dbo].[getFavoriteList]

as
begin

SET NOCOUNT ON

select manufacturer_name from dbo.Favorite_list
return
end

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

madhan
Yak Posting Veteran

59 Posts

Posted - 2014-09-25 : 15:39:21
Thanks for the reply. But I want all the manufacturer names in a variable and that needs to be returned to be used in C# code. Is it possibe?
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2014-09-25 : 15:42:53
A variable can only contain one value. There is no reason to use a variable here. Just return the result set and have C# process the record set that's returned.

Tara Kizer
SQL Server MVP since 2007
http://weblogs.sqlteam.com/tarad/
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2014-09-25 : 15:43:50
Yes, if you tell us in what format you want multiple manufacturers to be presented.


Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA
Go to Top of Page

madhan
Yak Posting Veteran

59 Posts

Posted - 2014-09-25 : 16:05:03
quote:
Originally posted by SwePeso

Yes, if you tell us in what format you want multiple manufacturers to be presented.


Microsoft SQL Server MVP, MCT, MCSE, MCSA, MCP, MCITP, MCTS, MCDBA



I am not sure because I am new to returning data from Stored procedures. Could you please direct me with some variable that needs to saved with all manufacturer names?
Go to Top of Page

madhan
Yak Posting Veteran

59 Posts

Posted - 2014-09-25 : 16:40:54
I want the output parameter specified in Stored procedure. Is it possible to return multiple manufacturer names in output parameter.

@manufacturer_name varchar(200) OUTPUT
Go to Top of Page

madhan
Yak Posting Veteran

59 Posts

Posted - 2014-09-25 : 16:46:43
quote:
Originally posted by madhan

I want the output parameter specified in Stored procedure. Is it possible to return multiple manufacturer names in output parameter.

@manufacturer_name varchar(200) OUTPUT

When I run the below t-sql the format that gave result is what I want as output value

select manufacturer_name from dbo.Favorite_list


Go to Top of Page
   

- Advertisement -