Solved

Incorrect Syntax error - Please heeelp!

Posted on 2009-04-07
7
157 Views
Last Modified: 2012-05-06
Dear experts,

I am using SQL  Server 2005 to code the following query but I just kept getting the following error:

Microsoft OLE DB Provider for ODBC Drivers error '80040e14'

[Microsoft][ODBC SQL Server Driver][SQL Server]Incorrect syntax near 'a'.

What am I doing wrong?

Any help is greatly appreciated.
SELECT 
  (SELECT COUNT(*)FROM tblMaster a,tblCODE cWHERE a.chsid=c.chsid and (c.Close_EmployedWhenReleased)='Y' and c. Start_Date > NULL and c. Start_Date < NULL and c. Close_Date > NULL and c.Close_Date < NULL ) AS A, 
 
(SELECT COUNT(*) FROM tblMaster a, tblCODE c WHERE a.chsid=c.chsid and UPPER(c.Close_RecvdJobTraining)='Y' and c.Start_Date > NULL and c. Start_Date < NULL and c.Close_Date > NULL and c. Close_Date < NULL ) AS B,
 
 (SELECT COUNT(*) FROM tblMaster a, tblCODE c WHERE a.chsid=c.chsid and UPPER(c.Close_OffPublicAssistance)='YES' and c. Start_Date > NULL and c.Setup_ Start_Date < NULL and c. Close_Date > NULL and c. Close_Date < NULL ) AS C
FROM xsystbl_SYSPARMS

Open in new window

0
Comment
Question by:sammySeltzer
  • 3
  • 3
7 Comments
 
LVL 39

Accepted Solution

by:
BrandonGalderisi earned 25 total points
ID: 24091363
line 2:

 (SELECT COUNT(*)FROM tblMaster a,tblCODE cWHERE a.chsid=c.chsid and (c.Close_EmployedWhenReleased)='Y' and c. Start_Date > NULL and c. Start_Date < NULL and c. Close_Date > NULL and c.Close_Date < NULL ) AS A,

should be:

 (SELECT COUNT(*)FROM tblMaster a,tblCODE c WHERE a.chsid=c.chsid and (c.Close_EmployedWhenReleased)='Y' and c. Start_Date > NULL and c. Start_Date < NULL and c. Close_Date > NULL and c.Close_Date < NULL ) AS A,

change:
"cWHERE" changed to "c where"
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 24091368
SELECT
  (SELECT COUNT(*)FROM tblMaster a,tblCODE c WHERE a.chsid=c.chsid and (c.Close_EmployedWhenReleased)='Y' and c. Start_Date > NULL and c. Start_Date < NULL and c. Close_Date > NULL and c.Close_Date < NULL ) AS A,
 
(SELECT COUNT(*) FROM tblMaster a, tblCODE c WHERE a.chsid=c.chsid and UPPER(c.Close_RecvdJobTraining)='Y' and c.Start_Date > NULL and c. Start_Date < NULL and c.Close_Date > NULL and c. Close_Date < NULL ) AS B,
 
 (SELECT COUNT(*) FROM tblMaster a, tblCODE c WHERE a.chsid=c.chsid and UPPER(c.Close_OffPublicAssistance)='YES' and c. Start_Date > NULL and c.Setup_Start_Date < NULL and c. Close_Date > NULL and c. Close_Date < NULL ) AS C
FROM xsystbl_SYSPARMS
0
 
LVL 28

Author Comment

by:sammySeltzer
ID: 24091464
chapmandew:

It worked great but what did I do wrong?

I don't see it please forgive my slow uptake.

Thanks very much.
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
LVL 60

Assisted Solution

by:chapmandew
chapmandew earned 25 total points
ID: 24091487
couple of things...

first, was here:  (*)FROM tblMaster a,tblCODE cWHERE a.chsid=c.

your c blended with your WHERE

second was here:
and c.Setup_Start_Date < NULL and c. Close_Date > NULL and c. Close_Date < NULL ) AS C

there was  space between c. and Close_Date
0
 
LVL 28

Author Comment

by:sammySeltzer
ID: 24091549
thanks very much
0
 
LVL 60

Expert Comment

by:chapmandew
ID: 24091565
welcome
0
 
LVL 28

Author Comment

by:sammySeltzer
ID: 24130952
I thought I closed this thread.

Sorry guys.

Again, thanks a lot BrandonGalderisi: and chapmandew:

Any of your solutions would have worked for me.
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
What is the best way to calculate hours worked 5 73
Sql Permission 6 65
Order by but want it in specific order 2 34
Query 14 57
This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
There are some very powerful Data Management Views (DMV's) introduced with SQL 2005. The two in particular that we are going to discuss are sys.dm_db_index_usage_stats and sys.dm_db_index_operational_stats.   Recently, I was involved in a discu…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

861 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