469,364 Members | 2,398 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,364 developers. It's quick & easy.

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 1961
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
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.