473,657 Members | 2,405 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 5486
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:UserMessa ge can be a good idea.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.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...@sommars kog.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:UserMessa ge can be a good idea.

--
Erland Sommarskog, SQL Server MVP, esq...@sommarsk og.se

Books Online for SQL Server 2005 athttp://www.microsoft.c om/technet/prodtechnol/sql/2005/downloads/books...
Books Online for SQL Server 2000 athttp://www.microsoft.c om/sql/prodinfo/previousversion s/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****@sommarsk og.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...@sommars kog.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...@sommarsk og.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****@sommarsk og.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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
18175
by: Karaoke Prince | last post by:
Hi There, I have an update statement to update a field of a table (~15,000,000 records). It took me around 3 hours to finish 2 weeks ago. After that no one touched the server and no configuration changed. Until yesterday, I re-ran it again and it took me more than 18hrs and still not yet finished!!! What's wrong with it? I can ran it successfully before. I have tried two times but the result was still the same.
3
8410
by: Alex | last post by:
Hi folks, Hopefully this is a simple fix, but I keep getting Syntax error with this statement in an MS SQL DTS statement and in Query Analyzer: Update A Set A.deptcode = A.deptcode, A.type = A.Type, a.TotalExpenseUnit = (a.LaborExpenseUnit + a.OtherExpenseUnit) Where a.Type in ('FYTD04', 'Prior Year','Budget') From Data_Unsorted A Join Data_Unsorted B On
5
5126
by: S.Patten | last post by:
Hi, I have a problem with updating a datetime column, When I try to change the Column from VB I get "Incorrect syntax near '942'" returned from '942' is the unique key column value However if I update any other column the syntax is fine
3
9100
by: markydev | last post by:
Hi, I'm using sql server 2000 sp4. I've 2 databases linked, an instance and my local. I'm getting two different errors when trying to update the remote table (local server) from the instance. There is only one row of data in the table with an identity field. 1st sql:- UPDATE ..dbo.NUMBERS SET =3
6
21006
by: vbnetrookie | last post by:
I have a table name in SQL Server 2000 that has a space in it ex: aim international I had trouble just in the query analyzer with this..I had to place the name in brackets for it to work. But now I'm in Visual Studio .Net 2003 and it gives me another problem. I get the table name from a drop down list selection and send it to a query string. But is gives me this error: *************** Line 1: Incorrect syntax near 'AIM international'.
4
3394
by: John Baker | last post by:
Hi: I have two tables, a setup table (TblSetup) and a purchase order table (tblPO). When i construct a query with ONLY the tblPO shown, and a type in parameter for the PO number, I an update the original tblPO. However, when I introduce the setup file into the query I cannot update the result. THis is true if I make a link to Setup or not. In fact, setup contains the client ID, which i wish to test against the client ID in the PO...
6
2684
by: FayeC | last post by:
I really need help figuring this out. i have a db with mostly text fields but 2. The user_id field is an autonumber (key) and the user_newsletter is a number (1 and 0) field meaning 1 yes the person wants to receive a newsletter and 0 no, don't want to receive it. Now.....when trying to create an UPDATE statement I am running into problems writing the code for it. I had issues before with missing commas but now that the commas are there...
6
1543
by: estark | last post by:
Hi there, I need to know how to update multiple records using 1 query. For example: UPDATE NPRG_Combined SET unsubscribe = '0' WHERE contact_id = '77214', '77215', '77216' This query gives me this error: Msg 102, Level 15, State 1, Line 3
1
3250
by: sibusiso | last post by:
HI Can Any one help I have extra field on a table like FDate, FYear, FMonth, FDay, FDatename I have a triger that I will update this field every time transaction hapened, this field must be updated to the curent date, year, month, date name I wrote something like.
0
8420
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8324
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8842
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8516
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8617
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7353
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6176
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.