471,851 Members | 860 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,851 software developers and data experts.

Stored procedure with resultset _

Hi,

I would like to write a stored procedure that returns a resultset.

e.g. select student_id, student_subject, subject_marks
from student_results
where student_class_no = ?

The input parameter is student_class_no (see ? as per above SQL).
The output is a resultset, with each result consisting of student_id,
student_subject, subject_marks.

Can anyone advise how this is done in sql server stored procedure?

Thanks,
June Moore.
Jul 20 '05 #1
1 2012
You can pass the value as a parameter to the proc and reference it in
your WHERE clause:

CREATE PROCEDURE GetStudentResults
@student_class_no
AS
SELECT
student_id,
student_subject,
subject_marks
FROM student_results
WHERE student_class_no = @student_class_no
GO

EXEC GetStudentResults 1
GO

--
Hope this helps.

Dan Guzman
SQL Server MVP

-----------------------
SQL FAQ links (courtesy Neil Pike):

http://www.ntfaq.com/Articles/Index....partmentID=800
http://www.sqlserverfaq.com
http://www.mssqlserver.com/faq
-----------------------

"June Moore" <ju******@yahoo.com.au> wrote in message
news:e5**************************@posting.google.c om...
Hi,

I would like to write a stored procedure that returns a resultset.

e.g. select student_id, student_subject, subject_marks
from student_results
where student_class_no = ?

The input parameter is student_class_no (see ? as per above SQL).
The output is a resultset, with each result consisting of student_id,
student_subject, subject_marks.

Can anyone advise how this is done in sql server stored procedure?

Thanks,
June Moore.

Jul 20 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

7 posts views Thread by Bill Kellaway | last post: by
3 posts views Thread by Michael | last post: by
2 posts views Thread by Dino L. | last post: by
3 posts views Thread by Amy | last post: by
aboka
reply views Thread by aboka | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.