Solved

SQL - "except" statements

Posted on 2008-06-12
3
787 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
3 Comments
 
LVL 11

Accepted Solution

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

Author Closing Comment

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

Peter.
0
 
LVL 5

Expert Comment

by:fesnyng
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
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 video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now