0

如果它不存在,我正在尝试将一行添加到数据库中,如果存在则更新该行。我在这个 SQL 语句中哪里出错了?

UPDATE Classes 
SET (Duration='44',
INModule='Actions',
EditionsFOR='Vocus VPR - Basic    Edition//Vocus PR - Enterprise Edition//',    
Objectives='objective 1//objective 2//objective 3//', 
PreReq='prerequisite   
1//prerequisite 2//prerequisite 3//',
Points='training point   1//training point 2//training point 3//',     
ContentLink='www.aol.com', 
OtherInfo='this is the internal info', 
Summary='this is a brief summary of the class') 
WHERE Title='this is the class title' 
IF @@ROWCOUNT=0 
INSERT INTO Classes (Title, Duration, INModule, EditionsFOR, Objectives, PreReq, 
Points, ContentLink, OtherInfo, Summary) 
VALUES ('this is the class title','44','Actions',
'Vocus VPR - Basic Edition//Vocus PR - Enterprise Edition//',
'objective 1//objective 2//objective 3//',
'prerequisite 1//prerequisite 2//prerequisite 3//',
'training point 1//training point 2//training point 3//',
'www.aol.com','this is the internal info',
'this is a brief summary of the class')
4

1 回答 1

1

去掉 . 周围的括号SET。应该这样写:

UPDATE Classes 
SET Duration    = '44', 
    INModule    = 'Actions', 
    EditionsFOR = 'Vocus VPR - Basic Edition//Vocus PR - Enterprise Edition//',
    Objectives  = 'objective 1//objective 2//objective       3//', 
    PreReq      = 'prerequisite 1//prerequisite 2//prerequisite 3//', 
    Points      = 'training point 1//training point 2//training point 3//', 
    ContentLink = 'www.aol.com', 
    ....
于 2013-04-05T09:50:55.997 回答