问题如题,
附详细代码(热心人帮我看下拉 :)),HIS是远程服务器:
CREATE proc spI_CZMoney ---------更新Client表和门诊表的金额
as
declare @ID numeric(18,0)
declare @SFRQ datetime
declare @MaxSFRQ datetime
declare @MinSFRQ datetime
declare @ClientNO varchar(50)
declare @Money numeric(12,2)
set @MaxSFRQ=(select max(SFRQ) from I_SFRQ)
if isnull(@MaxSFRQ,'')='' set @MaxSFRQ=''
alter table Client Disable trigger Client_Update
declare cur cursor for select ID,SFRQ,case when ZFPB=1 then -XJJE else XJJE end as Charge from HIS.temp.dbo.MS_MZXX
open cur
fetch next from cur into @ID,@SFRQ,@Money
while @@fetch_status=0
begin
insert into I_SFRQ(SFRQ) Values(@SFRQ)
set @MinSFRQ=(select Min(SFRQ) from HIS.temp.dbo.MS_MZXX where [email protected])
if dateDiff(day,@MinSFRQ,@SFRQ)=0
begin
set @ClientNO=(select top 1 MZHM from HIS.temp.dbo.MS_BRDA where [email protected])
update Client set TotalMoney=ISNULL(TotalMoney,0)[email protected] where [email protected] and ISNULL(Type,'')='初诊'
update Client_Diagnose set TotalMoney=ISNULL(TotalMoney,0)[email protected] where [email protected] and ISNULL(Type,'')='初诊'
end
fetch next from cur into @ID,@SFRQ,@Money
end
close cur
deallocate cur
alter table Client enable trigger Client_Update
GO
------解决方案--------------------
兄弟,我想问你下你是用ado来访问远程数据库的吗?
为什么我用ado来访问远程数据库总是报 "sa登陆失败,用户SA登陆失败,原因:未与信任的SERVER连接想关联." 的错误,但我在查询分析器里可以执行的.