Exercises for defining variables:
Stored procedures:
Stored procedures (stored procedure) are sometimes referred to as sproc. Stored procedures are stored in a database rather than in a separate file, with input parameters, output parameters, and return values.
In a database, the process of creating stored procedures is the same as creating other objects, except for the AS keyword that it uses. The basic syntax for a stored procedure is as follows:
CREATE procduer| PROC <sproc name>
[<parameter Name>[schema.] <data Type>[varying][=<default value>][out [put]][,
[<parameter Name>[schema.] <data Type>[varying][=<default value>][out [put]][,
...]]
[With
recompile| encryption| [EXECUTE as {caller| Self| owner|< ' user name ';}]
[For REPLICATION]
As
<code>| EXTERNAL NAME <assembly name>.<assembly class>
Example stored procedure one:
Execute stored procedure method one:
Execute stored procedure method two:
As stated above, a stored procedure can define a return value.
Example:
To modify a stored procedure example:
Use a stored procedure to find examples of information in three tables:
Example:
Example two:
Example three:
Exercise one: The topic is as follows
Example of receiving using the return value:
Example of a method that simply uses the return value:
When creating a stored procedure, we can set it to have a default value.
Example:
Practice One: Enter a number to 1~n and
Exercise two: Enter the student number to see the total score of the students ' classes
Exercise three: Define a @count receive return value to see if it contains the student
Database Fundamentals (exercises, stored procedures that define variables to query)