我的表包含以下列:
我正在使用Microsoft SQL Server 2008 R2(SP1)-10.50.2876.0(X64)2013年5月30日10:18:43版权所有(c)Windows NT 6.1(Build 7601)上的Microsoft Corporation Enterprise Edition(64位) :Service Pack 1)(管理程序)
和Microsoft SQL Server Management Studio 14.0.17277.0
我的查询是这样的:
contentEncoding
查询返回错误:
第15层状态1的第9行156消息 关键字“函数”附近的语法不正确。
答案 0 :(得分:3)
function
是T-SQL中的关键字。
尝试用方括号将其包围:
select * from dbo.InstallationErrorLog
where data = 'Input string was not in a correct format.'
and ErrorDate > GETDATE()-90
and [Function] ='ProcessTblFromCSV'
答案 1 :(得分:1)
您需要在[]
列周围加上方括号function
:
select *
from dbo.InstallationErrorLog
where data = 'Input string was not in a correct format.' and
ErrorDate > GETDATE()-90 and
[Function] ='ProcessTblFromCSV';
但是,不建议使用名称function
,它是保留关键字。第二件事,我将在此处使用dateadd()
而不是减法(-90
)上的blog:
因此,您可以改为:
select *
from dbo.InstallationErrorLog
where data = 'Input string was not in a correct format.' and
ErrorDate > DATEADD(DAY, -90, GETDATE()) and
[Function] ='ProcessTblFromCSV';