September 1st, 2012, 10:13 AM
[ASP SQL] INSERT INTO + SELECT + Variables Syntax Error
So I'm working in ASP Classic and I'm trying to write an SQL statement to insert into a table. The thing is, I want to use a select from AND I want to include some variables too.
I know this can be done, but no matter what I try I can't make it work. Could someone take a look at my sql statement and see what's wrong with it?
I've already confirmed that all of the table and field names are spelled correctly, and that all of the variables are populated. The error I'm currently getting is:
sqlstr = "INSERT INTO [Scores] (STUID, SKName, HUnit, SHom, WHom, WHomSc)" &_
"SELECT " & CInt(std) & ",Students.SKName," & wk & ",'" & spch & "','" &_
wrch & "'," & wrsc & " FROM [Students] WHERE Students.UnID = " & CInt(std) & ")"
Line 218 is my execute statement using the above sql string.
September 1st, 2012, 10:32 AM
The last right parenthesis should not be there.
September 1st, 2012, 11:03 AM
That was embarrassingly simple... thank you.