Home > database >  Stored procedure execution problems
Stored procedure execution problems

Time:10-02

I of the new one, and hope everybody bosses, glad to this period of the stored procedure should be how to use the exec implemented? I've tried many times have failed, I want to perform these one-time data, rather than a input
The create proc PROC1 (
@ Cno int, define local variables @ Cno, @ garade, @ graderank, @ stunum, @ counts
@ Garade int,
@ GradeRank int the output,
@ StuNum int the output,
@ counts int
) as
The begin
Select @ Garade=Garade from cs - to assign variables in the table to a local variable
The set @ counts=1
The set @ GradeRank=90
Select @ Cno=Cno from cs
The Begin - write a loop statement, let code shorter, is since 100 is set each section, each student number If statistics (@ counts<=10) - here is the cycle, cycle run ten times over the if (@ Garade>=@ GradeRank)
The set @ StuNum=(
Select count (Sno) from cs - here is the subquery
Where @ Garade>=@ GradeRank and @ Cno=18
)
The set @ GradeRank=@ GradeRank - 10
End
End
Go
, every brother please give advice or comments
  • Related