/*处理postran表*/
 
declare @oldMaxDate1 datetime /*提取本地"postran"中日期最大值*/
select oldMaxDate1=maxdatetime from maxindex where table_nm='1'
delete from postran where item_dt=@oldMaxDate1
/*导入到本地postran*/
insert into postran select * from OPENDATASOURCE('SQLOLEDB','integrated security=SSPI;data source=cshis;persist security info=false').thotel.dbo.postran where item_dt>=@oldMaxDate1/*提取远程表中的日期最大值*/
declare @newMaxDate1 datetime
/*更新maxindex表的第一条记录*/
select newMaxDate1=max(item_dt) from OPENDATASOURCE('SQLOLEDB','integrated security=SSPI;data source=cshis;persist security info=false').thotel.dbo.postran
update maxindex set maxdatetime=@newMaxDate1 where table_nm='1'我认为是那个变量的事,如果换成一个实际的参数就没问题了
如:insert into postran select * from OPENDATASOURCE('SQLOLEDB','integrated security=SSPI;data source=cshis;persist security info=false').thotel.dbo.postran where item_dt>='2004-5-1'
问题是@newMaxDate1可以获取到一个值!望高手指教!谢谢