Database Reference
In-Depth Information
Figure 7.22
Execute function fn_StudentInfo.
TASK 3: CREATE, MODIFY, AND EXECUTE STORED PROCEDURES
To create a stored procedure, you can execute the CREATE PROCEDURE statement in
New Query.
1. Enter the SQL statements below in the New Query editor:
CREATE PROCEDURE Grade_Change (@Sid INT, @Grade char, @ClassID
INT) AS
UPDATE STUDENT_CLASS
SET Grade = @Grade
WHERE StudentID = @Sid AND ClassID = @ClassID
2. Highlight the code and click Run . As shown in Figure 7.23, the procedure Grade_
Change is successfully created.
3. To modify a stored procedure, use the steps below. Type the following code in the
New Query editor:
ALTER PROCEDURE Grade_Change (@Sid INT, @Grade char, @ClassID
INT) AS
UPDATE [Class_Registration].[dbo].[STUDENT_CLASS]
SET Grade = @Grade
WHERE StudentID = @Sid AND ClassID = @ClassID
PRINT 'The grade is changed.'
4. Highlight the code and click Run . As shown in Figure 7.24, the procedure Grade_
Change is successfully altered.
Search WWH ::




Custom Search