我想通過在VBA中使用下面的sql語句將記錄插入另一個表中。當我嘗試運行它時,VBA說有一個語法錯誤,我相信它在第一行的參數中,但我不確定如何解決它。我對SQL很陌生,所以任何幫助將不勝感激。謝謝。插入SQL語法錯誤
"INSERT INTO Clients (Client ID)" & _
"SELECT DISTINCT DD.[Client ID] " & _
"FROM " & tableName & " as DD " & _
"Where DD.[Client ID] NOT IN (SELECT DD.[Client ID] FROM " & tableName & " as DD)"
UPDATE:滿弦:
INSERT INTO Clients (Client ID)SELECT DISTINCT DD.[Client ID] FROM FN_DataDump_ALL_11032014 as DD Where DD.[Client ID] NOT IN (SELECT DD.[Client ID] FROM as DD)
生成完整的字符串並將其發佈到您的問題中。 – DLeh 2014-12-03 15:56:16
爲什麼你一直在發佈相同的問題? – sgeddes 2014-12-03 15:58:24
你的'表名'是空的;你需要一個「)」後面的空格,並且你需要[]圍繞一個'客戶端ID'。我同意這是非常差的形式多次發佈相同的問題。留一個,直到完全解決! – 2014-12-03 16:02:13