Data to be processed: SPKFK (commodity storehouse):
(SPID,//Product inside Code PK
SPBH,//commodity number Unique Index
SPMCH,//Product name
SHPGG,//Product specifications
DW,//unit
SHPCHD//commodity origin)
The data source in the new system is SPKFK in the original system, and there is no SPID field in the original system, which needs to be generated during the import.
Attaching the old system business Database (DTX4) to the MSSQL2000
Perform the following actions:
Use ST70--New system business Database
DECLARE @tran_point int
Set @tran_point =@ @trancount--Get the number of system transactions
If @tran_point =0 begin tran Tran_c--Start transaction else save Tran Tran_c--Set transaction save point
Declare @spid char (11)--Define variable set @spid = '
DECLARE @id INT--Defining an internal code value variable
Set @id = 0--Initialize starting value
Select @spid as spid, SPBH, SPMCH, SHPGG, DW, shpchd into #t1-extract information from the original system from dtx40. Spkfk
If @ @error <>0 goto Err_lab
Update #t1 set spid= @id, @id = @id +1--Generate code values for merchandise
If @ @error <>0 goto Err_lab
Update #t1 set spid= ' SPH ' + REPLICATE (' 0 ', 8-len (LTrim (spid))) RTrim (+ltrim (SPID))--Generate the inner code of the product (the code for the product is: RTrim) If @ @error <>0 goto Err_lab
Delete from SPKFK--Empty the destination table if @ @error <>0 goto Err_lab
INSERT into SPKFK (spid, SPBH, SPMCH, SHPGG, DW, SHPCHD)-inserts data into the destination table select spid, SPBH, SPMCH, SHPGG, DW, shpchd from # T1
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.