我给你示例,你自己看:
USE [MySchool]
GO
/****** 根据用户名(帐号)查询管理员记录信息 ******/
CREATE PROCEDURE [dbo].[P_Admin_Select]
(
@loginId Varchar(50)
)
AS
Select AdminId,LoginId,LoginPwd From Admin Where LoginId=@loginId
Go
/****** 查询年级记录信息 ******/
CREATE PROCEDURE dbo.P_Grade_Select
AS
Select GradeId,GradeName From Grade
Go
/****** 通过年级名称得到年级ID ******/
CREATE PROCEDURE dbo.P_Grade_GetGradeIDByGradeName
(
@gradeName Varchar(50)
)
AS
Select GradeId,GradeName From Grade Where GradeName=@gradeName
GO
/****** 通过年级ID得到班级名称集合 ******/
CREATE PROCEDURE dbo.P_Class_SelectClassesByGradeID
(
@gradeId int
)
AS
Select ClassId,ClassName,GradeId From Class Where GradeId=@gradeId
Go
/****** 通过班级名称得到班级ID ******/
CREATE PROCEDURE dbo.P_Class_GetClassIDByClassName
(
@className Varchar(50)
)
AS
Select ClassId From Class Where ClassName=@className
Go
/****** 添员学员 ******/
Create PROCEDURE dbo.P_Student_Insert
(
@LoginId Varchar(50),
@LoginPwd Varchar(50),
@UserStateId Int,
@ClassId Int,
@StudentNO nvarchar(255),
@StudentName nvarchar(255),
@Sex nvarchar(255)
)
AS
Insert Into Student Values(@LoginId,@LoginPwd,@UserStateId,@ClassId,@StudentNO,@StudentName,@Sex)
Go
/****** 返回所有学员信息 ******/
CREATE PROCEDURE dbo.P_Student_Select
AS
Select * From Student
Go
/****** 根据学员用户名(登录ID)得到学员实体 ******/
CREATE PROCEDURE dbo.P_Student_GetStudentByLoginId
(
@LoginId Varchar(50)
)
AS
Select * From Student Where LoginId=@LoginId
GO
/****** 根据学员用户名(登录ID)删除学员 ******/
CREATE PROCEDURE dbo.P_Student_Delete
(
@LoginId Varchar(50)
)
AS
Delete From Student Where LoginId=@LoginId
GO
/****** 根据学员用户名(登录ID)修改学员 ******/
CREATE PROCEDURE dbo.P_Student_Update
(
@LoginId Varchar(50),
@LoginPwd Varchar(50),
@UserStateId Int,
@ClassId Int,
@StudentNo nvarchar(255),
@StudentName nvarchar(255),
@Sex nvarchar(255)
)
AS
Update Student Set LoginPwd=@LoginPwd,UserStateId=@UserStateId,ClassId=@ClassId,
StudentNo=@StudentNo,StudentName=@StudentName,Sex=@Sex Where LoginId=@LoginId
GO