473,586 Members | 2,639 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 5483
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
18170
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...
3
8409
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...
5
5125
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
9095
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
20997
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...
4
3389
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....
6
2683
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...
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
3249
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
7912
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...
0
7839
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...
0
8338
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7959
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...
0
8216
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...
0
3837
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2345
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1449
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1180
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.