?
Solved

SQL - "except" statements

Posted on 2008-06-12
3
Medium Priority
?
796 Views
Last Modified: 2012-06-27
Hi Experts

Some difficulty finding info on except arguments in SQL.  This query works up to line 3. Adding line 4 causes a syntax error . Some resource at EE says there is no "except" in SQL??? Can this query be written another way?

Many thanks

Peter
SQL = SQL & " select [PD_PatID], [PD_FName], [PD_LName]"
        SQL = SQL & " from PATIENT_DETAILS"
        SQL = SQL & " where [PD_Diabetic] = True"
        SQL = SQL & " except where [PD_Addr1] LIKE '*Tricare*'"

Open in new window

0
Comment
Question by:peterdarazs
[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 Comments
 
LVL 12

Accepted Solution

by:
Missus Miss_Sellaneus earned 1000 total points
ID: 21775546
Try changing line 4 to:
SQL = SQL & " AND NOT [PD_Addr1] LIKE '*Tricare*'"
0
 

Author Closing Comment

by:peterdarazs
ID: 31466811
OK,  that should do it. Many thanks and enjoy the day further.

Peter.
0
 
LVL 5

Expert Comment

by:fesnyng
ID: 21775662
Nice job Miss_Sellaneus.

There is an addition concern with your statement:

LIKE '*Tricare*'  is the same as =  '*Tricare*'

I suspect that you intended for the astericks ( * )  to be wildcard characters.  For SQL Server, the wildcard character would be %.  If you, however, you intended for the * characters to be there, then you would be better off using = (equals) instead of LIKE.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Ready to get certified? Check out some courses that help you prepare for third-party exams.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

649 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