不好意思,我用的是sqlserver,
同时,两台机器A[dragon]和B[liuliu],有相同表结构数据库,我想在A机器上写一个过程,能够查询B机器上的数据,同时能够查询A机器上的数据,然后将不同的数据丛A机器上拷到B机器上
CREATE procedure [dbo].[qcminsert] as
begin
DECLARE @QCMcode int
DECLARE @MatName varchar(30)
DECLARE @batchNo varchar(20)
DECLARE @QCPosition varchar(10)
DECLARE @Eqpcode int
DECLARE @IsUsed bit
DECLARE QCMCS cursor
for select QCMcode ,MatName , batchNo ,QCPosition,Eqpcode, IsUsed from liuliu.testdj.dbo.qc_material --此处报错,不能保存这个过程,除去liuliu后就行了
Open QCMCS
FEtch Next From QCMCS into
@QCMcode , @MatName , @batchNo , @QCPosition ,@Eqpcode, @IsUsed
WHILE (@@FETCH_status<>-1)
begin
if not exists(select qcmcode from qc_material where @MatName=Matname and @batchNo=batchno
and @QCPosition=QcPosition and @Eqpcode=eqpcode and @IsUsed=isUsed )
begin
insert into qc_material (QCMcode ,MatName , batchNo ,QCPosition,Eqpcode, IsUsed )
values(@QCMcode , @MatName , @batchNo , @QCPosition ,@Eqpcode, @IsUsed )
end
FEtch Next From QCMCS into
@QCMcode , @MatName , @batchNo , @QCPosition ,@Eqpcode, @IsUsed
end
close QCMCS
deallocate QCMCS
end
GO