2013-04-05 37 views
0

我想添加一行到數據庫,如果它不存在或更新行,如果它。我哪裏錯了?我已經看了它一千次,並認爲我可能會丟失一些愚蠢的東西...任何人都可以發現此SQL語句中的錯誤嗎? <resolved>

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') 
+0

它是做什麼的?無論如何它插入它? – 2013-04-05 09:52:21

+0

不,只是引發UPDATE語法錯誤。 – 2013-04-05 09:54:05

回答

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', 
    .... 
+0

謝謝馬哈茂德;這解決了這個UPDATE語法錯誤。現在它拋出以下錯誤: 查詢表達式中的語法錯誤(缺少運算符) – 2013-04-05 09:55:04

+0

UPDATE或INSERT命令上的新語法錯誤?你可以單獨運行命令嗎? – 2013-04-05 10:10:24

+0

運行INSERT INTO命令毫無問題。返回的錯誤如下: 查詢表達式'Title ='類的標題'IF @@ ROWCOUNT = 0時, ContentLink,OtherInfo,Summary)VALUES('課程名稱','48','Core','Vocus VPR - 基礎版// Vocus PR - 企業' – 2013-04-05 10:22:16

相關問題