消息8180,第16级,第1行,第1行声明无法准备。消息156,级别15,状态1,行1关键字'as'附近的语法不正确

时间:2018-01-18 19:46:49

标签: sql-server

select 
    F.NidLog, F.NidFormReport , ltrim(rtrim(F.Caption)), F.NidTask, 
    F.NidUser, F.UserName, F.ActionState, F.ActionDate, F.ActionTime, 
    W.NidProc, W.WorkflowTitel, W.BizCode, W.NidWorkItem, T.TaskTitel
from 
    openquery([192.168.12.69], '(select * from Esup..TaskLog) as F
                                inner join Esup..Task as T on T.NidTask  = F.NidTask
                                inner join Esup..WorkflowInstance as W on T.NidProc = W.NidProc')

执行上面显示的查询后,我收到此错误:

  

Msg 8180,Level 16,State 1,Line 1
  声明无法准备。

     

第15行,第1行,第1行,第1行   关键字'as'附近的语法不正确。

1 个答案:

答案 0 :(得分:1)

语法为OPENQUERY ( linked_server ,'query' )

删除了2个括号

from openquery ([192.168.12.69] , 'select * from Esup..TaskLog  as F 
inner join   Esup..Task as T on T.NidTask=F.NidTask
inner join  Esup..WorkflowInstance as W on T.NidProc=W.NidProc' )