Solved

SQL - "except" statements

Posted on 2008-06-12
3
792 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 250 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

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Running total between 2 sql tables in Sql 6 48
CAST issue with SQL 2000 15 44
SQL Convert rows to columns 5 32
Do not display comma when no last name 8 48
Composite queries are used to retrieve the results from joining multiple queries after applying any filters. UNION, INTERSECT, MINUS, and UNION ALL are some of the operators used to get certain desired results.​
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
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.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

737 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