中国IT动力,最新最全的IT技术教程
最新100篇 | 推荐100篇 | 专题100篇 | 排行榜 | 搜索 | 在线API文档
首 页 | 程序开发 | 操作系统 | 软件应用 | 图形图象 | 网络应用 | 精文荟萃 | 教育认证 | 硬件维护 | 未整理篇 | 站长教程
ASP JS PHP工程 ASP.NET 网站建设 UML J2EESUN .NET VC VB VFP 网络维护 数据库 DB2 SQL2000 Oracle Mysql
服务器 Win2000 Office C DreamWeaver FireWorks Flash PhotoShop 上网宝典 CorelDraw 协议大全 网络安全 微软认证
硬件维护  CPU  主板  硬盘  内存  显卡  显示器  键盘鼠标  声卡音箱  打印机  机箱电源  BIOS  网卡  C#  Java  Delphi  vs.net2005
  当前位置:> 程序开发 > 数据库开发 > 数据库综合
新旧系统切换中 资料内码 处理
作者:未知 时间:2005-07-27 23:38 出处:CSDN 责编:chinaitpower
              摘要:新旧系统切换中 资料内码 处理

原系统 :MSSQL SERVER 7.0+DELPHI

新系统 :MSSQL SERVER 2000 + DELPHI

需要处理资料:spkfk(商品库房库) :

                         (spid , //商品内码 pk

                          spbh ,//商品编号 Unique index 

                          spmch ,//商品名称

                          shpgg ,//商品规格

                          dw , //单位

                         shpchd //商品产地  )

新系统中资料来源为原系统中 SPKFK ,  原系统中无 SPID 字段 , 需在导入时生成。

将旧系统业务数据库(dtx4) 附加到MSSQL2000中

执行如下操作:


use st70 --新系统业务数据库

declare @tran_point int 

set @tran_point=@@trancount  --获取系统事务数

if @tran_point=0
  begin tran tran_c  --开始事务
else
  save tran tran_c  --设置事务保存点

declare @spid char(11) --定义变量
set @spid='' 

declare @id  int  --定义 内码 数值变量

set @id = 0  --初始化 起始 值

select @spid as spid , spbh ,spmch ,shpgg , dw ,shpchd  into  #t1    --提取原系统中 商品信息
from dtx40..spkfk

   if @@error<>0 goto err_lab

update #t1 set spid=@id ,@id=@id+1  -- 生成商品内码数值


   if @@error<>0 goto err_lab


update #t1 set spid='SPH' + REPLICATE('0',8-len(ltrim(rtrim(spid))))+ltrim(rtrim(spid)) --生成商品内码(商品内码为:SPHxxxxxxxxx)
   
  
   if @@error<>0 goto err_lab

delete from spkfk  --清空 目的表
  
  
   if @@error<>0 goto err_lab

insert into spkfk(spid , spbh , spmch ,shpgg ,dw ,shpchd)  --将数据插入到目的表
select spid , spbh , spmch ,shpgg ,dw ,shpchd from #t1

  
   if @@error<>0 goto err_lab

drop table #t1


if @tran_point=0  goto returnlb
 

err_lab:
       rollback tran tran_c  --取消事务

returnlb:
       commit tran tran_c   --提交事务

以上为商品资料的内码处理,其他资料同上。
      

  


关闭本页
 
首页 | 投资与合作 | 服务条款 | 隐私政策 | 收藏本站 | 设为首页 | 新用户注册 | 免责声明 | 使用帮助
Copyright ©2005-2008 chinaitpower.com All rights reserved. www.chinaitpower.com 版权所有