Web Hosting Talk







View Full Version : MSSQL syntax problem... argh!


croakingtoad
05-09-2008, 04:28 PM
What am I doing wrong here?


Incorrect syntax near the keyword 'WHERE'.

INSERT INTO pinnaclechart ('Transfer') VALUES ('0') WHERE (CommID = '260')


I'm about to pull out my hair.

stdunbar
05-09-2008, 06:10 PM
Do you mean to have that be an update? A where clause makes no sense with a single table insert. Perhaps you meant:


update pinnaclechart set 'Transfer' = 0' WHERE CommID = '260'


But that may be wrong, depending on what you're trying to do.

felikz
05-10-2008, 06:58 AM
stdunbar is right, a WHERE clause makes no sense in an INSERT statement.

If a row with a CommID of 260 already exists then you need to use the UPDATE statement, if it doesn't then you need to drop the WHERE clause.

Codebird
05-10-2008, 02:28 PM
[QUOTE=stdunbar;5102626]Do you mean to have that be an update? A where clause makes no sense with a single table insert. Perhaps you meant:


update pinnaclechart set 'Transfer' = 0' WHERE CommID = '260'



update pinnaclechart set 'Transfer' = '0' WHERE CommID = '260'

he forgot a ' before the 0 not to think his query is wrong and pull out your hair

stdunbar
05-11-2008, 08:13 PM
he forgot a ' before the 0 not to think his query is wrong and pull out your hair

Thanks Codebird - you're right - I don't want the OP spending time trying to get my syntax error to work!