TerryHogarth21
Board Regular
- Joined
- Mar 20, 2012
- Messages
- 245
I'm creating a SQL string in VBA to insert to a SQL table.
This syntax string is driving me nuts as I have an inaccurate syntax of an apostrophe or extra quotation somewhere when verifying each of the values
I want to ensure also that for the field types with data including Numbers in the SQL table and Excel I just need it to look like this
and for Text values it should include the apostrophe like this
.
For date fields that have values I think it's serial in Excel but date/time in SQL table so I'm assuming I don't need the apostrophe?
If anybody can clarify that would be great!
Thanks
This syntax string is driving me nuts as I have an inaccurate syntax of an apostrophe or extra quotation somewhere when verifying each of the values
Code:
sSQL = sSQL & " VALUES (" & _
"'" & Sheet28.Cells(lRow, 1) & "', " & "'" & Sheet28.Cells(lRow, 2) & ", " & "'" & Sheet28.Cells(lRow, 3) & "', " & "'" & Sheet28.Cells(lRow, 4) & "', " & "'" & Sheet28.Cells(lRow, 5) & "', " & "'" & Sheet28.Cells(lRow, 6) & "', " & "'" & Sheet28.Cells(lRow, 7) & "', " & "'" & Sheet28.Cells(lRow, 8) & "', " & "'" & Sheet28.Cells(lRow, 9) & "', " & _
I want to ensure also that for the field types with data including Numbers in the SQL table and Excel I just need it to look like this
Code:
Sheet28.cells(lRow, 1)
Code:
"'" & Sheet28.cells(lRow, 1) & "'"
For date fields that have values I think it's serial in Excel but date/time in SQL table so I'm assuming I don't need the apostrophe?
If anybody can clarify that would be great!
Thanks