Solved

SQL Query Access 2000 MDB file from delphi

Posted on 2011-03-09
6
647 Views
Last Modified: 2012-05-11
Hi Guys

i have a very strange problem querying a certain column within an access database. i can query any other table fine without issues but this one in specific is getting a pain.

my query is as follows

SELECT Scale.ScaleType, Scale.Sequence, Scale.size FROM Scale ORDER BY Scale.ScaleType

this will error on me but if i go into the mdb and double click the column name size and rename it to test. and retry my query

SELECT Scale.ScaleType, Scale.Sequence, Scale.test FROM Scale ORDER BY Scale.ScaleType

This will output the correct data without issue. i then rename it back to size and query again and it errors. unfortunatly i need to keep it as the sale column name because there is a retail system running off it and my querys are external for another purpose so the changes to the DB are easier said then done.

Scaletype = Number
Sequence = Number
Size = text
0
Comment
Question by:TG-Steve
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 
LVL 24

Expert Comment

by:jimyX
ID: 35082300
In SQL, as in many DBs, you can not use certain fields/columns/tables names that conflict with internal reserved words such as Size, Name, Index,...etc
But you can add additional character to be SSize or Siz.
0
 

Author Comment

by:TG-Steve
ID: 35082338
Hi Jimyx

What you state would certainly make sence and answer what has been happening. sorry i am a little lost in translation of the additional information you provided. is the additional characters to be added in the database or in the query and if so being the query could you please give me an example on how to execute this please

kind regards
steve
0
 
LVL 24

Expert Comment

by:jimyX
ID: 35082364
I mean the main name of the field in the DB.
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:TG-Steve
ID: 35082462
The problem i have is that the MDB in question is used by our retail software and i cannot alter it due to support issues and the fact it will probably crash the retail system. for a few months i have been working on an application that can pull tons of information out of the MDB and export it to a website MySql DB and everything seems to be working fine. However this issue now has always been there for me since i started exporting data and for the sake of argument i just renamed the field in a copied MDB for all my testing. Now i am at the point that everything works well but i need it to pull the information from the live MDB but i dont have the option to alter the inner tables etc.
0
 
LVL 6

Accepted Solution

by:
FactorB earned 500 total points
ID: 35082766
Just use square brackets in query

SELECT [Scale].[ScaleType], [Scale].[Sequence], [Scale].[Size] FROM [Scale] ORDER BY [Scale].[ScaleType]
in this case the engine will not look for reserved words inside brackets as are SELECT, ORDER ... and probably Size

Regards,
B.
0
 

Author Closing Comment

by:TG-Steve
ID: 35082825
Life Saver
0

Featured Post

Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
Suggested Courses

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question