SQL操作从本地数据库传到192.168.100.6中

来源:互联网 发布:dnf辅助源码2017 编辑:程序博客网 时间:2024/05/10 11:46

USE [ZKKQ]
GO
/****** Object:  StoredProcedure [dbo].[sp_send_tran_epbf303t]    Script Date: 11/04/2013 14:33:22 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author:  suhe
-- Create date: 04/11/2013
-- Description: v1.2
-- 将数据添加到erp中的gea400
-- =============================================

ALTER PROCEDURE [dbo].[sp_send_tran_epbf303t]
AS
BEGIN
-----------------
select  convert(varchar(100),[dbo].[Get_Check_Time](b.CHECKTIME),23) as work_dt,[dbo].[Get_Eat_Type](b.checktime) as eat_type,a.BADGENUMBER as emp_no,  [dbo].[Get_Check_Time](b.CHECKTIME) as eat_time,c.ID as machine_id,cre_uid=21741,cre_dt=getdate(),b.userid,CHECKTIME,c.sn
into #t_eat
from userinfo a,checkinout b,machines c
where (a.userid=b.userid and b.sn=c.sn and c.GroupCode='ST'and isnull(ERP_InterfaceYN,'NULL') ='N') 
-----------------
-----------------将数据添加到ny_db中的epbf303t
 insert into [192.168.100.6].ny_db.dbo.EPBF303T
(work_dt,eat_type,emp_no,eat_time,machine_id,cre_uid,cre_dt)
select  work_dt,eat_type,emp_no,eat_time,machine_id,cre_uid,cre_dt
from  #t_eat
-----------------
-----------------将数据添加到erp中的gea400
 insert into [192.168.100.6].erp.dbo.GEA400
(work_dt,eat_type,emp_no,eat_time,machine_id,cre_uid,cre_dt)
select  work_dt,eat_type,emp_no,eat_time,machine_id,cre_uid,cre_dt
from  #t_eat
----------------- 
 update b        
 set ERP_InterfaceYN ='Y'        
 from checkinout b,#t_eat d       
 where (b.userid=d.userid and b.checktime=d.checktime and b.sn=d.sn)  

-----------------
drop table #t_eat

-----------------
END