')'附近的语法不正确,可能错误地使用了substring()或charindex()?

时间:2021-12-16 00:37:51

I'm trying to run an ADODB query on a SQL Server database instance of ProjectWise, using the query defined by the following string:

我正在尝试使用以下字符串定义的查询在ProjectWise的SQL Server数据库实例上运行ADODB查询:

select 
dms_audt.o_acttime as actionTime,
dms_stat.o_statename as state,
dms_doc.o_filename as filename,
dms_doc.o_projectno as project 
from dms_audt 
inner join 
dms_stat 
on dms_audt.o_numparam2=dms_stat.o_stateno 
inner join dms_doc on dms_audt.objguid=dms_doc.o_docguid 
where substring(dms_doc.o_filename,1,4)="abcd") 
and charindex(dms_doc.o_filename,"efgh")=0

VBA is giving me a runtime error of:

VBA给我一个运行时错误:

Incorrect syntax near ')'

which makes me think that I'm either using substring() or charindex() incorrectly. I've received this error regardless of whether I wrap the abcd and efgh strings in single or double quotes. Any idea what I'm doing wrong here?

这让我觉得我正在使用substring()或charindex()错误。无论是用单引号还是双引号括起abcd和efgh字符串,我都收到了这个错误。知道我在这里做错了吗?

1 个解决方案

#1


5  

You have an extra bracket.

你有一个额外的支架。

this > where substring(dms_doc.o_filename,1,4)="abcd") and charindex(dms_doc.o_filename,"efgh")=0

这>其中substring(dms_doc.o_filename,1,4)=“abcd”)和charindex(dms_doc.o_filename,“efgh”)= 0

needs to be:

需要是:

where substring(dms_doc.o_filename,1,4)='abcd' and charindex(dms_doc.o_filename,'efgh')=0

其中substring(dms_doc.o_filename,1,4)='abcd'和charindex(dms_doc.o_filename,'e​​fgh')= 0

#1


5  

You have an extra bracket.

你有一个额外的支架。

this > where substring(dms_doc.o_filename,1,4)="abcd") and charindex(dms_doc.o_filename,"efgh")=0

这>其中substring(dms_doc.o_filename,1,4)=“abcd”)和charindex(dms_doc.o_filename,“efgh”)= 0

needs to be:

需要是:

where substring(dms_doc.o_filename,1,4)='abcd' and charindex(dms_doc.o_filename,'efgh')=0

其中substring(dms_doc.o_filename,1,4)='abcd'和charindex(dms_doc.o_filename,'e​​fgh')= 0