Windows 上的 MSSQL: 无法确定 SQL Server 实例的服务帐户

Microsoft.SQLServer.Windows.EventRule.DBEngine.Cannot_determine_the_service_account_for_SQL_Server_instance_1_5_Rule (Rule)

当 Transact-SQL 语句包含不匹配的单引号或双引号时,出现此错误。SET QUOTED_IDENTIFIER 设置将确定有效的单引号和双引号组合。有关 SET QUOTED_IDENTIFIER 的详细信息,请参阅联机丛书中的“SET QUOTED_IDENTIFIER”。

Knowledge Base article:

原因

当 Transact-SQL 语句包含不匹配的单引号或双引号时,出现此错误。SET QUOTED_IDENTIFIER 设置将确定有效的单引号和双引号组合。有关 SET QUOTED_IDENTIFIER 的详细信息,请参阅联机丛书中的“SET QUOTED_IDENTIFIER”。

用来标记文字字符串的开头的每个单引号或双引号必须有同样类型的相应引号来标记该文字字符串的末尾。单引号不能与双引号匹配来分隔单文字字符串。

属于文字字符串一部分的引号另作处理。如果单引号(')是文字字符串的一部分,则可用两个单引号('')表示。如果文字字符串由双引号分隔且 SET QUOTED_IDENTIFIER 为 OFF,则字符串可以包含内嵌单引号(如省略符号)。如果文字字符串由单引号分隔且 SET QUOTED_IDENTIFIER 为 ON 或 OFF,则字符串可以包含内嵌双引号。

如果您未在代码的各个位置放置正确的引号类型和数目,SQL Server 将返回上述错误,可能还有“在 % 附近有语法错误”错误。

有关管理代码中的引号的详细信息,请参阅这些 Microsoft 知识库文章:

311023311021

有关引号用法的示例,请参阅联机丛书中的“SET QUOTED_IDENTIFIER”。

解决方法

SELECT SESSIONPROPERTY('QUOTED_IDENTIFIER')

根据需要,您可能需要使用 SET QUOTED_IDENTIFIER ON/OFF 更改该设置。

可替代参数

名称

说明

默认值

已启用

启用或禁用工作流。

间隔(秒)

运行工作流的重复间隔时间(秒)。

300

优先级

定义警报优先级。

1

严重性

定义警报严重性。

1

同步时间

同步时间

 

超时(秒)

指定工作流在关闭之前允许运行的时间,并标记为失败。

200

数据库连接超时(秒)

如果在指定期间无法访问数据库,工作流将失败并注册一个事件。

15

Element properties:

TargetMicrosoft.SQLServer.Windows.DBEngine
CategoryEventCollection
EnabledTrue
Alert GenerateTrue
Alert SeverityWarning
Alert PriorityNormal
RemotableTrue
Alert Message
Windows 上的 MSSQL: 无法确定 SQL Server 实例的服务帐户
{0}
CommentMom2017ID='{9F3F26E8-EB1A-479F-A53F-BA44C789022D}';MOM2017GroupID={467ECC75-C5DA-42BD-955C-A73BBB51AF74}

Member Modules:

ID Module Type TypeId RunAs 
_F6DA1507_12AF_11D3_AB21_00A0C98620CE_ DataSource Microsoft.SQLServer.Windows.DataSource.EventCollectionFiltered Default
GenerateAlert WriteAction System.Health.GenerateAlert Default

Source Code:

<Rule ID="Microsoft.SQLServer.Windows.EventRule.DBEngine.Cannot_determine_the_service_account_for_SQL_Server_instance_1_5_Rule" Target="SqlDiscW!Microsoft.SQLServer.Windows.DBEngine" Enabled="true" ConfirmDelivery="true" Remotable="true" Comment="Mom2017ID='{9F3F26E8-EB1A-479F-A53F-BA44C789022D}';MOM2017GroupID={467ECC75-C5DA-42BD-955C-A73BBB51AF74}">
<Category>EventCollection</Category>
<DataSources>
<DataSource ID="_F6DA1507_12AF_11D3_AB21_00A0C98620CE_" Comment="{F6DA1507-12AF-11D3-AB21-00A0C98620CE}" TypeID="Microsoft.SQLServer.Windows.DataSource.EventCollectionFiltered">
<MachineName>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/MachineName$</MachineName>
<NetbiosComputerName>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/NetbiosComputerName$</NetbiosComputerName>
<InstanceName>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/InstanceName$</InstanceName>
<ConnectionString>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/ConnectionString$</ConnectionString>
<InstanceVersion>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/Version$</InstanceVersion>
<InstanceEdition>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/Edition$</InstanceEdition>
<MonitoringType>$Target/Property[Type="SqlDiscW!Microsoft.SQLServer.Windows.DBEngine"]/MonitoringType$</MonitoringType>
<SqlExecTimeoutSeconds>60</SqlExecTimeoutSeconds>
<SqlTimeoutSeconds>15</SqlTimeoutSeconds>
<TimeoutSeconds>200</TimeoutSeconds>
<IntervalSeconds>300</IntervalSeconds>
<SyncTime/>
<EventDisplayNumber>14353</EventDisplayNumber>
</DataSource>
</DataSources>
<WriteActions>
<WriteAction ID="GenerateAlert" TypeID="Health!System.Health.GenerateAlert">
<Priority>1</Priority>
<Severity>1</Severity>
<AlertMessageId>$MPElement[Name="Microsoft.SQLServer.Windows.EventRule.DBEngine.Cannot_determine_the_service_account_for_SQL_Server_instance_1_5_Rule.AlertMessage"]$</AlertMessageId>
<AlertParameters>
<AlertParameter1>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/MachineName$</AlertParameter1>
<AlertParameter2>$Target/Property[Type="SqlCoreLib!Microsoft.SQLServer.Core.DBEngine"]/InstanceName$</AlertParameter2>
<AlertParameter3>Event ID: $Data/Property[@Name='EventID']$. $Data/Property[@Name='Message']$</AlertParameter3>
</AlertParameters>
<Suppression>
<SuppressionValue/>
</Suppression>
</WriteAction>
</WriteActions>
</Rule>