vBulletin Search Engine Optimization
| |||||||
| Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| ||||
| 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. |
| ||||
| 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" <jungewum@yahoo.com.au> wrote in message news:e5dfaf21.0310080337.67afc1dc@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. |