Reputation: 221
Trying to insert the following values into a sql database from an excel macro
I get the following error message 'Incorrect Syntax near '('.
The code is...
Dim insert2 As String
insert2 = "INSERT INTO DETAIL" _
& " ( plant, taskno, commentno, commentby, commenton, comment, nextactionby) VALUES " _
& " ( 'UK' ((SELECT max(taskno) AS count from HEADER),'1', '" & UserID & "', CONVERT(datetime, '" & Hdate & "' ,103), '" & Dcomment & "', '" & Dnextactionby & "')"
Can anyone explain why this is happening?
Upvotes: 0
Views: 983
Reputation: 281835
You have a missing comma and some unbalanced parentheses here:
'UK' ((SELECT max(taskno) AS count from HEADER)
^ ^^ ^
Upvotes: 2