AndreaNobili
AndreaNobili

Reputation: 42957

Why does this update query not work?

I am pretty new with SQL Server and DBMS and I have some problem with the following query that upade a single record of a table named: MaliciousCodeAlertDocument

This is my query:

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

When I try to execute it I obtain the following error message:

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'.

What is the problem? How can I fix it?

Tnx

Upvotes: 1

Views: 679

Answers (1)

AHiggins
AHiggins

Reputation: 7219

Using double-quotes makes SQL Server think that the value within the quotes is a column, but it looks like you're trying to update it to a text value. If you use single quotes instead, SQL will recognize that you want to insert that value into your field, and should load it correctly.

EDIT: Sorry, didn't see that @scragar already posted this solution. Anyone know if I'm supposed to delete my answer because of this?

Upvotes: 7

Related Questions