473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 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 2056
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Bill Kellaway | last post by:
Hi there - this should be fairly simple for someone. Basically I can't figure out how to pass the parameters from ASP to a Stored Procedure on SQL. Here's my code: I just need to help in...
3
by: Jim Garrison | last post by:
I need to create a ResultSet in an Oracle Java Stored Procedure and return it to a PL/SQL caller. I've done quite a bit of research in Oracle's manuals and on the Web, and have found lots of...
3
by: Michael | last post by:
This one's really got me. I have a VB.NET (version 1.1.4322) project that provides an easy way to execute stored procedures on a generic level. When I run the code on computer A (running SQL...
2
by: KG | last post by:
Hi , I am looking for meta-information about the return recordset of a stored-procedure. The procedure returns a resultset that contains columns of more tables joined together. In all tables, I...
5
by: Raquel | last post by:
This is a very simple DB2 SQLJ stored procedure. The problem is that it seems to run fine but returns NOTHING. I mean..as if nothing has happened..not resultset is returned. I am passing value...
1
by: Raquel | last post by:
Have a question on the Stored procedure method code generated by DB2 development center for Java stored procedures. Suppose I have a requirement to return the resultset consisting of FIRSTNME,...
2
by: Twan Kennis | last post by:
Question: How do I pass a returning resultset from a nested Stored Procedure (which opens a cursor including option "WITH RETURN TO CALLER") as a returning resultset from it's own? When I...
2
by: Dino L. | last post by:
How can I run stored procedure (MSSQL) ?
3
by: Amy | last post by:
I'm having trouble getting some data into a datagrid. It works fine for the results of the first SELECT in the stored procedure, but not therafter. Here's the error I get: "A field or property...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.