Original system: MSSQL Server 7.0 Delphi
New system: MSSQL Server 2000 Delphi
Requires processing: SPKFK (Commodity Center):
(Spid, // Products PK
SPBH, // Product Number Unique Index
SPMCH, // Product Name
SHPGG, // Product Specification
DW, // unit
SHPCHD / / commercial site)
The source of information in the new system is the SPKFK in the original system. There is no SPID field in the original system, which is required to be generated during import.
Addition of the old system business database (DTX4) into the MSSQL2000
Perform the following:
Use ST70 - New System Business Database
Declare @Tran_Point Int
Set @Tran_point = @@TRANCOUNT - Get system transaction
IF @ Tran_Point = 0 Begin TRAN TRAN_C - Start Transaction Else Save TRAN_C - Set Transaction Save Point
Declare @SPID Char (11) - Define Variables Set @ spid = ''
Declare @ID int - Defines the inner code value variable
Set @ID = 0 - Initialization Start Value
Select @SPID AS SPID, SPBH, SPMCH, SHPGG, DW, SHPCHD INTO # T1 - Extraction of the product information from DTX40..spkfk
IF @@ error <> 0 goto err_lab
Update # t1 set spid = @ id, @ id = @ ID 1 - Generate a product number value
IF @@ error <> 0 goto err_lab
Update # T1 set spid = 'SPH' Replicate ('0', 8-Len (Ltrim (RTRIM (SPID)))) LTRIM (RTRIM (SPID)) - Generates Commodity Code (Household Code: SPHXXXXXXXXX ) IF @@ Error <> 0 goto err_lab
Delete from SPKFK - Clear Table IF @@ Error <> 0 goto err_lab
Insert Into Spkfk (SPID, SPBH, SPMCH, SHPGG, DW, SHPCHD) - Insert Data into Destination SPID, SPBH, SPMCH, SHPGG, DW, SHPCHD from FROM # T1
IF @@ error <> 0 goto err_lab
Drop Table # T1
Commit TRANTAN_C - Submit a transaction
Goto ReturnLB
ERR_LAB: ROLLBACK TRAN TRAN_C - Cancel Transaction
Returnlb: Return
The above-mentioned internal code processing, other information is the same.