Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > SQL Server > SQL Server 2000 > SQL Server 2000
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
SQL Server 2000 General discussion of Microsoft SQL Server -- for topics that don't fit in one of the more specific SQL Server forums. version 2000 only. There's a new forum for SQL Server 2005.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Server 2000 section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old January 11th, 2006, 04:02 AM
Registered User
 
Join Date: Nov 2005
Location: Cape Town, WC, South Africa.
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access Query

Hi All
Could someone assist me with this.I have an Access Query that I try to run but it keeps giving me an error.

[u]Error:-</u>Syntax Error(Missing Operator)In Query Expression 'Instrument.InstrumentCode = GroupsRelationships.Instr_Port_Id LEFT JOIN GroupsCategories On GroupsRelationships.CategoryId = GroupsCategories.CategoryId LEFT JOIN Groups On GroupsCategories.GroupId = Groups.GroupId LEFT JOIN InsCategory On (Instrument.'.

Query:-[u]</u>

SELECT Instrument.InstrumentCode, Instrument.InstrumentDescription, IIf( IsNull,'Unassigned',"GrpName") AS GrpName, IIf( IsNull,'Unassigned',"CategoryName") AS CatName,InsCategory.CategoryDescription, InsSubCategory.SubCategoryDescription,InsClass.Cla ssDescription FROM Instrument LEFT JOIN GroupsRelationships ON Instrument.InstrumentCode = GroupsRelationships.Instr_Port_ID
LEFT JOIN GroupsCategories ON GroupsRelationships.CategoryID = GroupsCategories.CategoryID
LEFT JOIN Groups ON GroupsCategories.GroupID = Groups.GroupID
LEFT JOIN InsCategory ON (Instrument.ReportDate = InsCategory.ReportDate
AND Instrument.RevisionDate = InsCategory.RevisionDate
AND Instrument.CategoryCode = InsCategory.CategoryCode
LEFT JOIN InsClass ON (Instrument.ClassCode = InsClass.ClassCode
AND Instrument.ReportDate = InsClass.ReportDate
AND Instrument.RevisionDate = InsClass.RevisionDate
LEFT JOIN InsSubCategory
ON Instrument.SubCategoryCode = InsSubCategory.SubCategoryCode
AND Instrument.ReportDate = InsSubCategory.ReportDate
AND Instrument.RevisionDate = InsSubCategory.RevisionDate
WHERE Instrument.RevisionDate = DateValue('" & RevisionDate & "')
AND Instrument.ReportDate = DateValue('" & ReportDate & "')
AND Groups.GroupName = ('" & Groups(0) & "')
AND Groups.GroupType = ('" & GroupType & "')
ORDER BY Instrument.InstrumentCode, GroupsRelationships.GroupID DESC ,
GroupsRelationships.CategoryID DESC ,
InsCategory.CategoryDescription, InsSubCategory.SubCategoryDescription, InsClass.ClassDescription
Reply With Quote
  #2 (permalink)  
Old January 11th, 2006, 08:40 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts
Default

Without getting into the syntax, Access uses ANSI 89, and SQL 2000 uses ANSI 92, so there may be some syntax screwing this up.

In any event, the better thing to do is to create your query on the SQL server and then just call the result set from the SQL view instead of pulling ALLLLLL the data, and then sorting it on the client.

SQL server will further optimize the view once created, and this will further speed the process.

If you need to further refine the results once on the client machine, just pull the initial query results into a temporary table on the client, and then run additional queries against it there.

HTH

mmcdonal
Reply With Quote
  #3 (permalink)  
Old January 11th, 2006, 08:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: Hudson, MA, USA.
Posts: 839
Thanks: 0
Thanked 1 Time in 1 Post
Default

Looks like you're missing at least one ")".

Shouldn't
Code:
... LEFT JOIN InsCategory ON (Instrument.ReportDate = InsCategory.ReportDate
AND Instrument.RevisionDate = InsCategory.RevisionDate
AND Instrument.CategoryCode = InsCategory.CategoryCode
LEFT JOIN InsClass ...
be
Code:
...LEFT JOIN InsCategory ON (Instrument.ReportDate = InsCategory.ReportDate
AND Instrument.RevisionDate = InsCategory.RevisionDate
AND Instrument.CategoryCode = InsCategory.CategoryCode)
LEFT JOIN InsClass ...
You should also consider being consistent in using parenthesis - some of your compound JOIN conditions have them, some don't, making it difficult for a human to parse them.

Jeff Mason
Custom Apps, Inc.
www.custom-apps.com
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Access query from a webpage? oldmainframehack Access VBA 1 August 13th, 2007 12:29 PM
MS Access Query rsm42 ASP.NET 1.0 and 1.1 Basics 2 March 20th, 2007 12:32 PM
Help with access query jrobertson Access VBA 6 January 25th, 2007 05:49 PM
need access query kale_tushar Access 2 January 3rd, 2005 05:26 AM
Access: need a Query. please help me... alienscript Access VBA 1 December 14th, 2003 01:02 PM



All times are GMT -4. The time now is 10:55 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.