MS SQL syntax

Martin

Lifer
Jan 15, 2000
29,178
1
81
I could really use some help with this. I have the most ordinary UPDATE statements, but SQL server is giving me "incorrect syntax".

for example...
UPDATE mapdata set parentID = '<something>' where nodeID = <something>"

is returning " Incorrect syntax near '='., ".

interesting thing is, an update statment without any WHERE clauses works fine.


I had a similar problem earlier... "delete * FROM table" wasn't working, but when I changed it to "DELETE FROM table" it works.

Anybody got a clue? Google isn't helping me.
 

91TTZ

Lifer
Jan 31, 2005
14,374
1
0
Yes, I'll take Potent Potables for $500, Alex.


(hey, if I can't answer your question, at least I could give you a free bump...)
 

Gunslinger08

Lifer
Nov 18, 2001
13,234
2
81
What's the data type of nodeID? Sounds like it might be a char/varchar/string, which needs ' ' around it.

delete * from is incorrect syntax.. that's why it didn't work. You can't selectively delete columns that way.
 

Deeko

Lifer
Jun 16, 2000
30,215
11
81
the delete statement works that way cuz you're taking out the whole row...as for the update statement, that looks about right to me...
 

torpid

Lifer
Sep 14, 2003
11,631
11
76
Need quotes around nodeId's value assuming it is a char field. Delete from table deletes all rows unless you put in a where clause; I assume you know this.
 

Martin

Lifer
Jan 15, 2000
29,178
1
81
no, its not the var types. The program was working fine with an ACCESS/ODBC connection. then we got a new sql server and needed to move everything there, so we just made an ODBC connection point to SQL server instead of Access. This caused some problems, but this UPDATE thing is the only thing left :

its just not making any sense....

 

EmperorIQ

Platinum Member
Sep 30, 2003
2,003
0
0
I'm assuming youre using a language like php or asp to connect and execute your queries, try priting the query, and see what happens.

for example in php you may have

<?php

$ID1 = 0;
$ID2 = 1;

$update = "UPDATE set ID = $ID1 WHERE another_id = $ID2";

?>

a problem may occur if either one of your variables $ID1 or $ID2 is empty.
 

torpid

Lifer
Sep 14, 2003
11,631
11
76
OK, so:

1) You in fact DO have a mapdata table where the parentID is a char but not the nodeID?
2) You in fact DID paste the SQL or just typed some random syntax expecting us to troubleshoot? You realize you don't have a space after the end quote for the parentID right?
3) Why are you using ODBC instead of OLEDB (or, if it's .net, a native SQL driver)?
 

GeekDrew

Diamond Member
Jun 7, 2000
9,100
13
81
EmperorIQ's suggestion is something that is probably the case; also, check to see if you need to have ` marks around field names.... such as

UPDATE `mapdata` SET `parentID` = '<something>' WHERE `nodeID` = <something>

<edit>

No clue if this applies to you. I'm only familiar with MySQL and PHP.
 

Xede

Senior member
Oct 15, 1999
420
0
0
Listen to EmeperorIQ and GeekDrew. It's either:

1) You're using a blank value for NodeID
2) You're using a non-numeric value for NodeID
3) You're using a numeric value for NodeID, but NodeID is actually a character field, so you need single quotes around the value.

Output the actual query to see what you're feeding it.
 
Feb 19, 2001
20,158
20
81
Easiest way to check. SSH in or use phpMyAdmin and type in the SQL query. Check teh errors.

Finally, if you're doing this in PHP or any language, just make sure you print/echo your variables before hand. DEBUG!
 

Martin

Lifer
Jan 15, 2000
29,178
1
81
ok, so it turns out the problem was that the nodID field lost its Autoincrement property when it was moved from access to MSSQL.

bah.

 
sale-70-410-exam    | Exam-200-125-pdf    | we-sale-70-410-exam    | hot-sale-70-410-exam    | Latest-exam-700-603-Dumps    | Dumps-98-363-exams-date    | Certs-200-125-date    | Dumps-300-075-exams-date    | hot-sale-book-C8010-726-book    | Hot-Sale-200-310-Exam    | Exam-Description-200-310-dumps?    | hot-sale-book-200-125-book    | Latest-Updated-300-209-Exam    | Dumps-210-260-exams-date    | Download-200-125-Exam-PDF    | Exam-Description-300-101-dumps    | Certs-300-101-date    | Hot-Sale-300-075-Exam    | Latest-exam-200-125-Dumps    | Exam-Description-200-125-dumps    | Latest-Updated-300-075-Exam    | hot-sale-book-210-260-book    | Dumps-200-901-exams-date    | Certs-200-901-date    | Latest-exam-1Z0-062-Dumps    | Hot-Sale-1Z0-062-Exam    | Certs-CSSLP-date    | 100%-Pass-70-383-Exams    | Latest-JN0-360-real-exam-questions    | 100%-Pass-4A0-100-Real-Exam-Questions    | Dumps-300-135-exams-date    | Passed-200-105-Tech-Exams    | Latest-Updated-200-310-Exam    | Download-300-070-Exam-PDF    | Hot-Sale-JN0-360-Exam    | 100%-Pass-JN0-360-Exams    | 100%-Pass-JN0-360-Real-Exam-Questions    | Dumps-JN0-360-exams-date    | Exam-Description-1Z0-876-dumps    | Latest-exam-1Z0-876-Dumps    | Dumps-HPE0-Y53-exams-date    | 2017-Latest-HPE0-Y53-Exam    | 100%-Pass-HPE0-Y53-Real-Exam-Questions    | Pass-4A0-100-Exam    | Latest-4A0-100-Questions    | Dumps-98-365-exams-date    | 2017-Latest-98-365-Exam    | 100%-Pass-VCS-254-Exams    | 2017-Latest-VCS-273-Exam    | Dumps-200-355-exams-date    | 2017-Latest-300-320-Exam    | Pass-300-101-Exam    | 100%-Pass-300-115-Exams    |
http://www.portvapes.co.uk/    | http://www.portvapes.co.uk/    |