CREATE PROCEDURE DInstitute_Insert @InstituteNO nvarchar(6),@InstituteName nvarchar(40) AS declare @return int,@count int if(ltrim(rtrim(@InstituteName))='' or ltrim(rtrim(@InstituteNO))='') select @return=3--返回3表示提交的数据有空值 else begin select @count=count(1) from DInstitute where InstituteNO=@InstituteNO if(@count>0) select @return=1--返回1表示编号有重复 else begin insert into DInstitute (InstituteNO,InstituteName) values (@InstituteNO,@InstituteName) if(@@error>0) select @return=2--返回2表示数据操作错误 else select @return=0--返回0表示数据操作成功 end end return @return GO