Solved

Incorrect Syntax error - Please heeelp!

Posted on 2009-04-07
7
150 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
In SQL Server, when rows are selected from a table, does it retrieve data in the order in which it is inserted?  Many believe this is the case. Let us try to examine for ourselves with an example. To get started, use the following script, wh…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

758 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now