CREATE PROCEDURE [dbo].[ProcAddTeacherInfo]( @UN varchar(50), @TN nvarchar(50), @TT varchar(50), @TE varchar(50), @TG bit, @szm varchar(50) ) AS BEGIN if not exists (select * from Teacher where UserNum=@UN) begin insert into Teacher(UserNum,TeacherName,TeacherTel,TeacherEmail,TeacherGender,szm)values(@UN,@TN,@TT,@TE,@TG,@szm) end else begin update Teacher set TeacherName=@TN,TeacherTel=@TT,TeacherEmail=@TE,TeacherGender=@TG,szm=@szm where UserNum=@UN end END
查询是否存在相同的usernum 若有 则修改信息,若无 则添加