Solved

syntax error - in know these records are there

Posted on 2013-02-01
7
233 Views
Last Modified: 2013-02-01
I know data values exist for this string below.  Am I doing something wrong in the syntax

select * from tblJJDP where Fiscal = 2012 and not IVPA = 'I'
0
Comment
Question by:al4629740
7 Comments
 
LVL 65

Expert Comment

by:Jim Horn
ID: 38844648
Possibly, but without access to your data source it's hard to tell.

Knee-jerk reactions...

>Fiscal = 2012
this works if Fiscal is some kind of Numeric.  If it's a char then you'll need Fiscal = '2012'

>and not IVPA = 'I'
and IVPA <> 'I' would be a little cleaner
verify that you want AND instead of OR
Verify that there is capital I, and not also lowercase i records that you want in your results
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 38844653
>Fiscal = 2012
Also if Fiscal is a date then Year(Fiscal) = 2012
0
 
LVL 3

Expert Comment

by:Nalinkumarbalaji
ID: 38844694
Try this one

select * from tblJJDP where Fiscal ='2012' and IVPA <> 'I'

Go with jimhorn comment
0
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

Author Comment

by:al4629740
ID: 38844727
still nothing.

I do notice that many values in IVPA have either an 'I' or NULL
0
 
LVL 65

Accepted Solution

by:
Jim Horn earned 300 total points
ID: 38844747
>many values in IVPA have either an 'I' or NULL
You'll have to handle the NULL values then, something like using COALESCE, which returns the first non-null value between the parentheses:

select *
from tblJJDP
where Fiscal = 2012 and COALESCE(IVPA, 'foo') <>  'I'
0
 
LVL 32

Assisted Solution

by:awking00
awking00 earned 200 total points
ID: 38844793
Another method -
select * from tblJJdp where Fiscal = 2012
except
select * from tblJJdp where IVPA = 'I'
0
 

Author Comment

by:al4629740
ID: 38844816
Thats crazy I never knew that.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
Via a live example, show how to set up a backup for SQL Server using a Maintenance Plan and how to schedule the job into SQL Server Agent.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

839 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