Home > Database > Mysql Tutorial > SQL编程:存储过程+事务处理+回滚+数据迁移

SQL编程:存储过程+事务处理+回滚+数据迁移

WBOY
Release: 2016-06-07 14:53:21
Original
1227 people have browsed it

最近给学校在做一个.NET网站,名字叫做文正学院过程化成绩录入系统,其中需要用到老用户登陆系统需要从旧系统里将以前存在的数据导入到新数据表中, ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 USE [new_

  最近给学校在做一个.NET网站,名字叫做文正学院过程化成绩录入系统,其中需要用到老用户登陆系统需要从旧系统里将以前存在的数据导入到新数据表中,

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

USE [new_wzjw]

GO

/****** Object:  StoredProcedure [dbo].[成绩管理_过程化成绩录入_数据迁移]    Script Date: 2014/3/16 22:55:38 ******/

SET ANSI_NULLS ON

GO

SET QUOTED_IDENTIFIER ON

GO

 

create proc [dbo].[成绩管理_过程化成绩录入_数据迁移]

 @kcId jxrw_code/*自定义变量名*/

as

begin

 

    begin try

        begin tran

        INSERT INTO [web_inputCj_xsxkb]

                ([xh] ,[xm],[xxxzdm],[xxxzmc],[cjxzdm],[kcid],[lrsj],[manuAdd])

            select xh, xm, xxxzdm,xxxzmc, cjxzdm, kcid, lrsj, manualAdd

            from web_inputCj_cjb as a where a.kcId = @kcId

            and not exists ( select * from web_inputCj_xsxkb as b

                where a.xh = b.xh and a.kcId = b.kcid )

 

        commit tran

        return 0

 

    end try

    begin catch

        rollback tran

        return 1

    end catch

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template