We help IT Professionals succeed at work.

a script that accepts user input

jphilli
jphilli asked
on
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
Comment
Watch Question

BRONZE EXPERT

Commented:
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.
Commented:
CREATE FUNCTION fnCourseTerms
      (@enrollmentNum int =0)
      RETURNS TABLE
RETURN
      (SELECT * FROM Course
      WHERE Enrollment >= @enrollmentNum)

Author

Commented:
I figured out using other means.

Explore More ContentExplore courses, solutions, and other research materials related to this topic.