加入 我创建一个存储过程:
create porc AB_CDE
@A int,
@B int
as
这里面就是内容了
就在阵容里面具体 操作 存储过程~~~~~~~~
给一个例子:
--插入时要判断是否重复插入
declare @id int
declare @sNo varchar(100)
declare @sName varchar(100)
declare @sex varchar(10)
declare @jiguan varchar(100)
declare @gongzuodanwei varchar(200)
declare @zhiwu varchar(100)
declare @tongxundizhi varchar(200)
declare @youzhengbianma varchar(100)
declare @lianxidianhua varchar(100)
declare @yidongdianhua varchar(100)
declare @dianziyouxiang varchar(100)
declare @shenfenzheng varchar(100)
declare @chushengriqi datetime
declare @xueli varchar(100)
declare @biyexuexiao varchar(100)
declare @biyezhuanye varchar(100)
declare @biyenianyue datetime
declare @xuewei varchar(100)
declare @mingzhu varchar(100)
declare @zhengzhimianmao varchar(100)
declare @regDate datetime
declare @result int
set @result=0
set @regDate=getdate()
begin tran
declare cur cursor for select 学号,姓名,性别,籍贯,工作单位,职务,通讯地址,邮政编码,联系电话,移动电话,电子邮箱,身份证号码,出生日期,学历,毕业学校,毕业专业名称,毕业年月,学位,民族,政治面貌 from #tmp
open cur
fetch next from cur into @sNo,@sName,@sex,@jiguan,@gongzuodanwei,@zhiwu,@tongxundizhi,@youzhengbianma,@lianxidianhua,@yidongdianhua,@dianziyouxiang,@shenfenzheng,@chushengriqi,@xueli,@biyexuexiao,@biyezhuanye,@biyenianyue,@xuewei,@mingzhu,@zhengzhimianmao
while @@fetch_status=0
begin
--学生在学生表中不存在才插入
if not exists (select 1 from vtd02 where 学号=@sNo)
begin
--插入学生资料
exec @id=PTD02_Insert @F01=@sName,@F02=@sex,@F36=@sNo,@FIDTB01=@classId,@F32=10,@F05=@jiguan,
@F17=@gongzuodanwei,@F15=@zhiwu,@F11=@tongxundizhi,
@F07=@youzhengbianma,@F10=@lianxidianhua,@F09=@yidongdianhua,
@F08=@dianziyouxiang,@F18=@shenfenzheng,@F06=@chushengriqi,
@F43=@xueli,@F12=@biyexuexiao,@F13=@biyezhuanye,
@F14=@biyenianyue,@F44=@xuewei,@F04=@mingzhu,@F45=@zhengzhimianmao
--插入学生帐号
exec PUB02_Insert @F01=@sNo,@F02=@password,@FIDUB01=3,@FIDF03=@id,@F04=1,@F05=@regDate
fetch next from cur into @sNo,@sName,@sex,@jiguan,@gongzuodanwei,@zhiwu,@tongxundizhi,@youzhengbianma,@lianxidianhua,@yidongdianhua,@dianziyouxiang,@shenfenzheng,@chushengriqi,@xueli,@biyexuexiao,@biyezhuanye,@biyenianyue,@xuewei,@mingzhu,@zhengzhimianmao
end
else
begin
fetch next from cur into @sNo,@sName,@sex,@jiguan,@gongzuodanwei,@zhiwu,@tongxundizhi,@youzhengbianma,@lianxidianhua,@yidongdianhua,@dianziyouxiang,@shenfenzheng,@chushengriqi,@xueli,@biyexuexiao,@biyezhuanye,@biyenianyue,@xuewei,@mingzhu,@zhengzhimianmao
end
end
close cur
deallocate cur
if @@error<>0 rollback tran
commit tran
上面比如是一个存储过程。
然后: exec PUB02_Insert @F01=@sNo,@F02=@password,@FIDUB01=3,@FIDF03=@id,@F04=1,@F05=@regDate
这个就是在上面掉用的存储过程。 exec 存储过程name 具体参数