472,145 Members | 1,787 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,145 software developers and data experts.

UPDATE query gives Incorrect Syntax error

Hi all

I'm running SQL Server 2005 Express Edition.
One database
One table called Sites
Fields as follows:
id (bigint, Identity, Primary Key)
SiteName (varchar(50), allows nulls)
Generation (float)
LastUpdated (varchar(50), allows nulls)

At present there are only three records in this table.

My VB application connects via ODBC (using Named Pipes) no problems.
SELECT queries run as expected and return appropriate records.
When I run an UPDATE query like this one:
UPDATE Sites SET (Generation = 44) WHERE (SiteName = 'Test')
I get the following error:
-2147217900 [Microsoft][ODBC SQL Server Driver][SQL
Server]Incorrect syntax near '26'.

Now the funny thing is that the field LastUpdated did contain
'26/08/2008' but I have changed the field value and still get the same
error message.
Restarting SQL Server does not fix the problem nor does rebooting the
machine.
The query works perfectly from inside the Management Studio but not
via ODBC.
The ODBC connection is fine so I don't think this is a security/
permissions problem.

I'd appreciate some advice.

Chris
Aug 26 '08 #1
5 5384
Chris Kennedy (ch****@clarke-energy.com) writes:
I'm running SQL Server 2005 Express Edition.
One database
One table called Sites
Fields as follows:
id (bigint, Identity, Primary Key)
SiteName (varchar(50), allows nulls)
Generation (float)
LastUpdated (varchar(50), allows nulls)

At present there are only three records in this table.

My VB application connects via ODBC (using Named Pipes) no problems.
SELECT queries run as expected and return appropriate records.
When I run an UPDATE query like this one:
UPDATE Sites SET (Generation = 44) WHERE (SiteName = 'Test')
I get the following error:
-2147217900 [Microsoft][ODBC SQL Server Driver][SQL
Server]Incorrect syntax near '26'.

Now the funny thing is that the field LastUpdated did contain
'26/08/2008' but I have changed the field value and still get the same
error message.
Restarting SQL Server does not fix the problem nor does rebooting the
machine.
The query works perfectly from inside the Management Studio but not
via ODBC.
The ODBC connection is fine so I don't think this is a security/
permissions problem.
Interesting. Are there any triggers on the table?

If there is not, my suspicion that you are somehow mistaken about the
statement that causes the error. Using Profiler and including the events
Error:Exception and Error:UserMessage can be a good idea.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Aug 26 '08 #2
On Aug 26, 3:56*pm, Erland Sommarskog <esq...@sommarskog.sewrote:
>
Interesting. Are there any triggers on the table?

If there is not, my suspicion that you are somehow mistaken about the
statement that causes the error. Using Profiler and including the events
Error:Exception and Error:UserMessage can be a good idea.

--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Books Online for SQL Server 2005 athttp://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books...
Books Online for SQL Server 2000 athttp://www.microsoft.com/sql/prodinfo/previousversions/books.mspx- Hide quoted text -

- Show quoted text -
Hi Erland

No - no triggers on the table.
Indeed it was just a case of creating a new database, add a table and
add fields.
I suspect you may be right about the statement that is causing the
error message however the UPDATE query is the only statement I am
trying to run.
Is it possible that a previous query has somehow become trapped and is
being retried by SQL Server when I am trying to run my query?
I'll investigate the use of the Profiler to try and determine exactly
what is going on.
Can you point me to an online tutorial for the Profiler as the MSDN
wasn't that easy to follow?

Chris

Aug 26 '08 #3
Chris Kennedy (ch****@clarke-energy.com) writes:
No - no triggers on the table.
Indeed it was just a case of creating a new database, add a table and
add fields.
I suspect you may be right about the statement that is causing the
error message however the UPDATE query is the only statement I am
trying to run.
Is it possible that a previous query has somehow become trapped and is
being retried by SQL Server when I am trying to run my query?

Rather something the client API is doing behind your back.
I'll investigate the use of the Profiler to try and determine exactly
what is going on.
Can you point me to an online tutorial for the Profiler as the MSDN
wasn't that easy to follow?
It's not that difficult. Start Profiler, select New Trace complete the
Connection Dialog. In the dialog that comes up, click the Events Selection
tab. Down to the right there is a check box, Show All Events. Check this
one. Then in the grid find the Error group. In this group, check the
Exception and User Message events. If you are alone on the server, you
can press Run now. If there is more activity, you will find need to
set up a Column filter.

All and all, I believe Profiler is quite easy to get started with. The
GUI is fairly intuitive. It may be difficult to understand what all
those events and columns are, but you don't have to understand all
of them at once. There is a default selection of columns, and often
this is sufficient.

There are some buttons in the toolbar that permits you to stop and start
a trace.

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000: http://www.microsoft.com/sql/prodinf...ons/books.mspx

Aug 26 '08 #4
On Aug 27, 7:08*am, Erland Sommarskog <esq...@sommarskog.sewrote:
It's not that difficult. Start Profiler, select New Trace complete the
Connection Dialog. In the dialog that comes up, click the Events Selection
tab. Down to the right there is a check box, Show All Events. Check this
one. Then in the grid find the Error group. In this group, check the
Exception and User Message events. If you are alone on the server, you
can press Run now. If there is more activity, you will find need to
set up a Column filter.

All and all, I believe Profiler is quite easy to get started with. The
GUI is fairly intuitive. It may be difficult to understand what all
those events and columns are, but you don't have to understand all
of them at once. There is a default selection of columns, and often
this is sufficient.

There are some buttons in the toolbar that permits you to stop and start
a trace.

--
Erland Sommarskog, SQL Server MVP, esq...@sommarskog.se

Links for SQL Server Books Online:
SQL 2008:http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005:http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx
SQL 2000:http://www.microsoft.com/sql/prodinf...ons/books.mspx
I have just discovered that SQL Server 2005 Express Edition does not
contain the Profiler tool. Any suggestions for an alternative or
workaround?

Chris
Aug 26 '08 #5
Chris Kennedy (ch****@clarke-energy.com) writes:
I have just discovered that SQL Server 2005 Express Edition does not
contain the Profiler tool. Any suggestions for an alternative or
workaround?
Sorry, I kind of vainly hoped that you would have a license of DevEdition
around.

You can still run a server-side trace, but that is admittedly a more
difficult and is not as convenient for quick debugging.

A license of Developer Edition is not that expensive, and getting access to
Profiler may alone warrant the cost. You could also download and install
Evaluation Edition.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Aug 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Karaoke Prince | last post: by
reply views Thread by Saiars | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.