?
Solved

SQL - "except" statements

Posted on 2008-06-12
3
Medium Priority
?
794 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
This article shows gives you an overview on SQL Server 2016 row level security. You will also get to know the usages of row-level-security and how it works
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Viewers will learn how to use the SELECT statement in SQL to return specific rows and columns, with various degrees of sorting and limits in place.
Suggested Courses

771 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