user3013325
user3013325

Reputation: 221

SQL server 08 incorrect syntax near ')'

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

Answers (1)

RichieHindle
RichieHindle

Reputation: 281835

You have a missing comma and some unbalanced parentheses here:

'UK' ((SELECT max(taskno) AS count from HEADER)
   ^ ^^                                       ^

Upvotes: 2

Related Questions