carlosespada
Posts: 5
|
| Posted: 12/27/2006, 7:59 AM |
|
I am trying to insert records from one table to another using SQL but am having a problem inserting some variables along with the records. Here is my code, probably just a syntax error:
putSQL = "INSERT INTO SurveyResponses (SurveyQuestionID, UserID )" & _
"VALUES (" & "SELECT SurveyQuestions.SurveyQuestionID FROM SurveyQuestions WHERE Active = 1 AND ClientID=" & ClientID & "," & CCDLookUp("max(UserID)","Users","", Connection) & ")"
The error im getting is: Incorrect Syntax near the keyword 'SELECT'
What am I doing wrong?
_________________
Skysoft Incorporated- A Professional Software Development Company |
 |
 |
matheus
Posts: 386
|
| Posted: 12/27/2006, 8:26 AM |
|
Take off ( {parenthesis} after VALUES.
putSQL = "INSERT INTO SurveyResponses (SurveyQuestionID, UserID )" & _
"VALUES " & "SELECT SurveyQuestions.SurveyQuestionID FROM SurveyQuestions WHERE Active = 1 AND ClientID=" & ClientID & "," & CCDLookUp("max(UserID)","Users","", Connection) & ""
_________________
Matheus Trevizan
Dynamix Software Ltda.
Blumenau SC Brasil
www.dynamix.com.br |
 |
 |
carlosespada
Posts: 5
|
| Posted: 12/27/2006, 9:30 AM |
|
I tried removing the ( and the ) but still am getting the same error....
_________________
Skysoft Incorporated- A Professional Software Development Company |
 |
 |
peterr
Posts: 5971
|
| Posted: 12/27/2006, 12:45 PM |
|
I would try replacing "putSQL =" with Response.Write (you can also add Response.End on the next line), then test your syntax directly in the database.
_________________
Peter R.
YesSoftware Forums Moderator
For product support please visit http://support.yessoftware.com |
 |
 |
Edd
Posts: 547
|
| Posted: 12/27/2006, 2:26 PM |
|
Try
putSQL = "INSERT INTO SurveyResponses (SurveyQuestionID, UserID ) " & _
" SELECT SurveyQuestions.SurveyQuestionID, " & Connection.ToSQL(CCDLookUp("max(UserID)","Users","", Connection),ccsInteger) & " FROM SurveyQuestions WHERE Active = 1 AND ClientID=" & Connection.ToSQL(ClientID,ccsInteger)
Edd
_________________
Accepting and instigating change are life's challenges.
http://www.syntech.com.au |
 |
 |
carlosespada
Posts: 5
|
| Posted: 12/27/2006, 5:50 PM |
|
Edd is the MAN!!!! But he already knew this, works perfect! Thank you!
_________________
Skysoft Incorporated- A Professional Software Development Company |
 |
 |
|