我是SQL Server和DBMS的新手,我在以下查询中遇到了一些问题:查询了一个名为的表的单个记录: MaliciousCodeAlertDocument
这是我的疑问:
UPDATE MaliciousCodeAlertDocument
SET Discovered = GetDate(),
LastUpdated = GetDate(),
SourceId = "UP",
MalCodeID = 1,
Title = "UPDATED",
Origin = "UP",
Type = "UP",
Feature = "UP",
Risk = "UP",
Severity = 1,
OverallImpact = 1,
ContagionPotential = 1,
Wild = "UP",
AlertStatusID = 1,
AttributeType = 1,
DetailLevel = 1 ,
Language = 1 ,
Summary = "UP" ,
Symptom = "UP" ,
TechnicalDescription = "UP" ,
MitigatingStrategy = "UP" ,
Disinfection = "UP" ,
URL = "UP"
WHERE Id = 11316
当我尝试执行它时,我收到以下错误消息:
Msg 207, Level 16, State 1, Line 1
Invalid column name 'UP'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'UPDATED'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'UP'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'UP'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'UP'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'UP'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'UP'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'UP'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'UP'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'UP'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'UP'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'UP'.
Msg 207, Level 16, State 1, Line 1
Invalid column name 'UP'.
有什么问题?我该如何解决?
TNX
答案 0 :(得分:7)
使用双引号使SQL Server认为引号中的值是一列,但看起来您正在尝试将其更新为文本值。如果您使用单引号,SQL将识别您要将该值插入到字段中,并应正确加载它。
编辑:对不起,没看到@scragar已经发布了这个解决方案。任何人都知道我是否应该删除我的答案?