sql 语句 select * from openquery 使用问题

有远程链接服务器[202.104.242.70]
及表x_退货主表 退货单号='TTTS002-200809-001'
执行以下语句老是出错,请问到底要怎么改才不出错!
declare @day varchar(8)
set @day='20080109'
select * from openquery([202.104.242.70],'select * from x_退货主表 where substring(退货单号,9,8)=@day')

出错信息:
服务器: 消息 8180,级别 16,状态 1,行 8
Statement(s) could not be prepared.
服务器: 消息 137,级别 15,状态 1,行 8
Must declare the variable '@day'.
[OLE/DB provider returned message: 无法完成延迟准备。]

第1个回答  2014-05-12
我也遇到了同样的问题,在本机是可以正常执行sql语句的,在远程服务器上执行
SELECT *
FROM OPENROWSET
就一直报错,不知道怎么办了,唉~~
相似回答