• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 203
  • Last Modified:

a script that accepts user input

I need to use a function to return records for all classes with an enrollment of more than a particular number input by a specified user. As well as write a script that will accept a users input and invoke the function.

I am really unsure where I should start here!!
The columns in my table are like so
Course_ID
Ref_Number
Faculty_ID
Term
Enrollment
TotRev
0
jphilli
Asked:
jphilli
  • 2
1 Solution
 
Nico BontenbalCommented:
The function on SQL Server can be a 'stored procedure' with a parameter. It would look something like this:
Create procedure CourseWithEnrollment(@MinEnrollments as int)
as
select 
    Course_ID,
    Ref_Number,
    Faculty_ID,
    Term,
    Enrollment,
    TotRev
from 
    Course
where
    Enrollment >= @MinEnrollments

Open in new window


You can invoke this procedure like this:
exec CourseWithEnrollment 10

Open in new window


Not sure what you mean by 'a script that accepts user input'. You need some kind of client application for this. That could be Excel, MS Access, HTML, VBScript etc. So I need some more information to know what you need.
0
 
jphilliAuthor Commented:
CREATE FUNCTION fnCourseTerms
      (@enrollmentNum int =0)
      RETURNS TABLE
RETURN
      (SELECT * FROM Course
      WHERE Enrollment >= @enrollmentNum)
0
 
jphilliAuthor Commented:
I figured out using other means.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now