Groups | Blog | Home
all groups > sql server programming > may 2004 >

sql server programming : can store procedure return result ??


Aaron [SQL Server MVP]
5/30/2004 12:08:58 PM
You're going to have to show sample data and desired results given different
calls to the stored procedure. I can't make heads or tails of your
narrative.

--
Aaron Bertrand
SQL Server MVP
http://www.aspfaq.com/
(Reverse e-mail to reply.)






[quoted text, click to view]

Partha Mandayam
5/30/2004 1:42:25 PM
Your stored procedure is returning a resultset consisting of name,
address, etc so I am not clear what you want.
You are already doing what you want to do!

Regards

Partha Mandayam
Software Consultant
Home page: http://partha.tripod.com


*** Sent via Developersdex http://www.developersdex.com ***
Hugo Kornelis
5/30/2004 10:27:01 PM
[quoted text, click to view]

Hi Agnes,

Do you mean like this?

CREATE PROCEDURE dbo.companyinfo_shipper_search
@searchcode varchar(10),
@name varchar(25) output,
@address1 varchar(50) output,
@address2 varchar(50) output,
@address3 varchar(50) output,
@address4 varchar(50) output
as
select @name = name, @address1 = address1, @address2 = address2,
@address3 = address3, @address4 = address4
from companyheader
where code = @searchcode
GO


Best, Hugo
--

Agnes
5/30/2004 11:59:03 PM
I know how to pass the parameter to store procedure, however, can it return
some item results ???
I want to get back the name,address1---4, Thanks a lot

my code is
CREATE PROCEDURE dbo.companyinfo_shipper_search
@searchcode varchar(10)

as
select code,name,country,address1,address2,address3,address4 ,telno,faxno
from companyheader
where code = @searchcode
GO

From Agnes

Partha Mandayam
5/31/2004 1:09:34 PM
Here's how you need to run this stored procedure in Query Analyzer

--Create variables to hold output parameters


declare @name varchar(25),
declare @address1 varchar(50),
declare @address2 varchar(50) ,
declare @address3 varchar(50),
declare @address4 varchar(50)

--execute sp

exec dbo.companyinfo_shipper_search 'testcode',
@name output, @address1 output, @address2 output, @address3 output,
@address4 output

Then you should not get any error. Make sure you have created the stored
procedure exactly as suggested by Hugo.

[quoted text, click to view]


Regards

Partha Mandayam
Software Consultant
Home page: http://partha.tripod.com


*** Sent via Developersdex http://www.developersdex.com ***
Agnes
5/31/2004 11:58:09 PM
Dear Hugo,
As I run the following programe , I got an error in SQL Analyzer
Procedure 'companyinfo_shipper_search' expects parameter '@name', which was
not supplied.
What does it mean ?? Please help ~~~

[quoted text, click to view]

Tom Moreau
6/1/2004 9:56:44 AM
Remove the commas at the end of each DECLARE.

--
Tom

---------------------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinnaclepublishing.com/sql


[quoted text, click to view]
declare @name varchar(25),
declare @address1 varchar(50),
declare @address2 varchar(50) ,
declare @address3 varchar(50),
declare @address4 varchar(50)

exec dbo.companyinfo_shipper_search 'testcode',
@name output, @address1 output, @address2 output, @address3 output,
@address4 output

Thanks Partha Mandayam, Do u mean I put the above code in SQL analyzer and
run it ??
However, I am fail again. it said "Server: Msg 156, Level 15, State 1, Line
2
Incorrect syntax near the keyword 'declare'.


Please help ~~

Agnes
6/1/2004 9:49:59 PM
declare @name varchar(25),
declare @address1 varchar(50),
declare @address2 varchar(50) ,
declare @address3 varchar(50),
declare @address4 varchar(50)

exec dbo.companyinfo_shipper_search 'testcode',
@name output, @address1 output, @address2 output, @address3 output,
@address4 output

Thanks Partha Mandayam, Do u mean I put the above code in SQL analyzer and
run it ??
However, I am fail again. it said "Server: Msg 156, Level 15, State 1, Line
2
Incorrect syntax near the keyword 'declare'.


Please help ~~

Roji. P. Thomas
6/2/2004 10:33:37 AM
I strongly recommend you to test the code in the solution
you are providing. Otherwise explicitly state that it is not tested.

--
Roji. P. Thomas
SQL Server Programmer
[quoted text, click to view]

AddThis Social Bookmark Button