sql get all surname with out A and B

Posted on 2011-04-26
Last Modified: 2012-05-11

I have an sql table which is called customer

i am writing the following query

select Code,
from customer
where surname not like 'A%' or suname not like 'B%'

but it is still returning surnames begining with A and B, what i want is to return surnames that do not start with A or B

Please help


Question by:R8VI
    LVL 4

    Accepted Solution

    Use the following query

    select Code,
    from customer
    where surname not like 'A%' and suname not like 'B%'

    LVL 4

    Expert Comment

    Try this ... let me know if it worked ???

    select *
    from customer
    where upper(surname) not like 'A%' or upper(surname) not like 'B%'

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Suggested Solutions

    Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
    JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
    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.
    Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.

    732 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

    21 Experts available now in Live!

    Get 1:1 Help Now