原系統(tǒng) :mssql server 7.0+delphi
新系統(tǒng) :mssql server 2000 + delphi
需要處理資料:spkfk(商品庫(kù)房庫(kù)) :
(spid , //商品內(nèi)碼 pk
spbh ,//商品編號(hào) unique index
spmch ,//商品名稱
shpgg ,//商品規(guī)格
dw , //單位
shpchd //商品產(chǎn)地 )
新系統(tǒng)中資料來源為原系統(tǒng)中 spkfk , 原系統(tǒng)中無 spid 字段 , 需在導(dǎo)入時(shí)生成。
將舊系統(tǒng)業(yè)務(wù)數(shù)據(jù)庫(kù)(dtx4) 附加到mssql2000中
執(zhí)行如下操作:
use st70 --新系統(tǒng)業(yè)務(wù)數(shù)據(jù)庫(kù)
declare @tran_point int
set @[email protected]@trancount --獲取系統(tǒng)事務(wù)數(shù)
if @tran_point=0 begin tran tran_c --開始事務(wù)else save tran tran_c --設(shè)置事務(wù)保存點(diǎn)
declare @spid char(11) --定義變量set @spid=''
declare @id int --定義 內(nèi)碼 數(shù)值變量
set @id = 0 --初始化 起始 值
select @spid as spid , spbh ,spmch ,shpgg , dw ,shpchd into #t1 --提取原系統(tǒng)中 商品信息from dtx40..spkfk
if @@error<>0 goto err_lab
update #t1 set [email protected] ,@[email protected]+1 -- 生成商品內(nèi)碼數(shù)值
if @@error<>0 goto err_lab
update #t1 set spid='sph' + replicate('0',8-len(ltrim(rtrim(spid))))+ltrim(rtrim(spid)) --生成商品內(nèi)碼(商品內(nèi)碼為: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) --將數(shù)據(jù)插入到目的表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 --取消事務(wù)
returnlb: commit tran tran_c --提交事務(wù)
以上為商品資料的內(nèi)碼處理,其他資料同上。
注冊(cè)會(huì)員,創(chuàng)建你的web開發(fā)資料庫(kù),