I am using EXCEL macros/vba to insert data from the xls sheet into a SQL database.
Can anyone explain why I am getting this error message...
INCORRECT SYNTAX NEAR 'OPEN'
The code I run is an insert statement
Dim insert As String
insert = "INSERT INTO dbo.HEADER
(plant,
taskno,
tskstatus,
category,
opened,
openedby,
title)
VALUES
( 'UK',
(select Max(taskno) AS count from HEADER)+ 1),
'open',
'RFSA',
CONVERT(datetime,'" & strdate & "',103),
'" & UserId & "',
'" & strtitle & "')"
The code inserts the following into a SQL database.
'OPEN' is just a value I am trying to insert into a collumn..