22,209
社区成员
发帖
与我相关
我的任务
分享
USE [HERP_BHYY]
GO
/****** 对象: StoredProcedure [dbo].[sp_GetHISChargeOReceiptDataInHISDBbyDay] 脚本日期: 12/03/2013 08:36:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_GetHISChargeOReceiptDataInHISDBbyDay] @ImpDate as DATETIME
AS
BEGIN
--SET NOCOUNT ON;
DECLARE @ST_DATE AS DATETIME
DECLARE @ED_DATE AS DATETIME
DECLARE @TEMP_DATE DATETIME
IF @ImpDate is not null
begin
SET @ST_DATE=LEFT(@ImpDate,10)
SET @ED_DATE=dateadd(day,1,@ST_DATE)
end
delete hisdb2.dbo.his_charge_acc_o where charge_date>=@ST_DATE and charge_date<@ED_DATE
insert into hisdb2.dbo.his_charge_acc_o
(charge_date, deposit_pre, pay_type_code, patient_type_code, his_irecord, charge_money, patient_code, invoice_no, operator, acc_flag, balance_flag, invoice_type)
select charge_date, deposit_pre, pay_type_code, patient_type_code, his_irecord, charge_money, patient_code, invoice_no, operator, acc_flag, balance_flag, invoice_type
from openquery(HIS,'select charge_date, deposit_pre, pay_type_code, patient_type_code, his_irecord, charge_money, patient_code, invoice_no, operator, acc_flag, balance_flag, invoice_type from data_hrp.HIS_CHARGE_ACC_o')
where charge_date>=@ST_DATE and charge_date<@ED_DATE
end
USE [HERP_BHYY]
GO
/****** 对象: StoredProcedure [dbo].[sp_GetHISChargeOReceiptDataInHISDBbyDay] 脚本日期: 12/03/2013 08:36:35 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[sp_GetHISChargeOReceiptDataInHISDBbyDay] @ImpDate as DATETIME
AS
BEGIN
--SET NOCOUNT ON;
DECLARE @ST_DATE AS DATETIME
DECLARE @ED_DATE AS DATETIME
DECLARE @TEMP_DATE DATETIME
IF @ImpDate is not null
begin
SET @ST_DATE=LEFT(@ImpDate,10)
SET @ED_DATE=dateadd(day,1,@ST_DATE)
end
begin tran
delete hisdb2.dbo.his_charge_acc_o where charge_date>=@ST_DATE and charge_date<@ED_DATE
commit tran
begin tran
insert into hisdb2.dbo.his_charge_acc_o
(charge_date, deposit_pre, pay_type_code, patient_type_code, his_irecord, charge_money, patient_code, invoice_no, operator, acc_flag, balance_flag, invoice_type)
select charge_date, deposit_pre, pay_type_code, patient_type_code, his_irecord, charge_money, patient_code, invoice_no, operator, acc_flag, balance_flag, invoice_type
from openquery(HIS,'select charge_date, deposit_pre, pay_type_code, patient_type_code, his_irecord, charge_money, patient_code, invoice_no, operator, acc_flag, balance_flag, invoice_type from data_hrp.HIS_CHARGE_ACC_o')
where charge_date>=@ST_DATE and charge_date<@ED_DATE
commit tran
end