首页 > 解决方案 > 最近添加的表列上的 SQL“关键字附近的语法不正确”(编辑:列名是保留字)

问题描述

我的表包含以下列:

我正在使用 Microsoft SQL Server 2008 R2 (SP1) - 10.50.2876.0 (X64) 2013 年 5 月 30 日 10:18:43 版权所有 (c) Microsoft Corporation Enterprise Edition (64-bit) o​​n Windows NT 6.1 (Build 7601: Service Pack 1) (管理程序)

和 Microsoft SQL Server Management Studio 14.0.17277.0

我的查询是这样的:

select * from dbo.InstallationErrorLog  
where data = 'Input string was not in a correct format.' 
   and ErrorDate > GETDATE()-90 
   and Function ='ProcessTblFromCSV'

查询返回错误:

消息 156,级别 15,状态 1,第 9 行关键字“功能”附近的语法不正确。

标签: sql-servertsql

解决方案


function是 T-SQL 中的关键字。

尝试用括号括起来:

select * from dbo.InstallationErrorLog  
where data = 'Input string was not in a correct format.' 
   and ErrorDate > GETDATE()-90 
   and [Function] ='ProcessTblFromCSV'

推荐阅读