Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9247237
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:40:42+00:00 2026-06-18T09:40:42+00:00

The following only returns surnames that are one character long. Can I add a

  • 0

The following only returns surnames that are one character long.
Can I add a further condition so that it only returns Latin alphabet characters i.e. A-Z (plus a-z)

SELECT Surname
FROM WHData.dbo.vw_DimUser
WHERE 
    LEN(Surname) =1
    AND <extra condition required>
GROUP BY Surname
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T09:40:43+00:00Added an answer on June 18, 2026 at 9:40 am
    SELECT Surname
    FROM WHData.dbo.vw_DimUser
    WHERE 
        LEN(Surname) = 1
        AND Surname like '[a-Z]'
    GROUP BY Surname
    

    Wildcard matching

    Edit after comment below:

    Let’s test:

    create table t1 (c1 char(1) collate Latin1_General_CS_AS
                     , c2 char(1) collate Latin1_General_CS_AS
                     , wild1 varchar(10) collate Latin1_General_CS_AS
                    , wild2 varchar(10) collate Latin1_General_CS_AS)
    
    insert into t1 values ('A', 'a', '[A-z]', '[a-Z]')
    
    select match1 = case when c1 like wild1 then 'Matched' else 'Unmatched' end
      , match2 = case when c1 like wild2 then 'Matched' else 'Unmatched' end
      , match3 = case when c2 like wild1 then 'Matched' else 'Unmatched' end
      , match4 = case when c2 like wild2 then 'Matched' else 'Unmatched' end
    from t1
    

    enter image description here

    You can see that both A and a are only matched correctly when [a-Z] is used as the match pattern.

    SQL Fiddle for example.

    This can be explained in the answer to this previous SO question. Basically, with Latin1_General_CS_AS, SQL server will sort characters like:

    a
    A
    b
    B
    

    However, to steal from the question again, Books Online states:

    In range searches, the characters included in the range may vary depending on the sorting rules of the collation.
    

    So I guess it’s COLLATION dependent to some extent, so really a case of testing in any particular environment where something liken this is deployed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have multiple messages in SQS. The following code always returns only one, even
How can I subset the following example data frame to only return one observation
Possible Duplicate: PHP String in Array Only Returns First Character I've got following problem.
I have been tried the following query and it succeeds (only returns the one
I would like to only insert a row, if the following SELECT returns a
I considered the following experinment: simple C program, that only return 0, but linked
Can anyone explain why the following jquery only fires the 2nd toggle event and
I have a new iPhone app that has the following (and only the following)
I have readonly access to the master database however the following query only returns
While trying to make an overview of added friends, the following code only returns

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.