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

  • Home
  • SEARCH
  • 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 3948848
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T01:25:25+00:00 2026-05-20T01:25:25+00:00

This is a sequel to my (other) dumb question that I have asked today

  • 0

This is a sequel to my (other) dumb question that I have asked today

I have a stored proc in SQL Server which needs to select certain rows based on a keyword, like:

@Key varchar(5) = 'a'

select * From Products where ProductName like 'a%'

now, the @Key can contain values like 0-9 and XYZ apart from all the other normal characters from A, B to W

so when @Key is XYZ it needs to select all products which starts from letters X, Y, OR Z and when its 0-9 it should select any products which starts from numbers.

so what I have is this now:

WHERE
(@Key='xyz' and (name like 'x%' or name like 'y%' or name like 'z%'))
or name LIKE @Keyword +'%'

and now, to get the proc to pickup numbers, I should do something similar to the XYZ but includes name like '0%' or name like '1%' ten times.

Surely, there should be a better way to ask SQL Server to select with names starting from decimal?

is this the only way to do it?

thanks.

sorry if I am asking too many questions!

  • 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-05-20T01:25:25+00:00Added an answer on May 20, 2026 at 1:25 am

    The LIKE statement also allows for wild cards in a single character, eg

    SELECT...
    WHERE foo LIKE '[0-9]%'
    

    will return values where foo begins with a digit.

    Similarly,

    SELECT...
    WHERE foo LIKE '[aeiou]%'
    

    will return values where foo begins with a vowel.

    Check the documentation for LIKE – there are a few more tricks…

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

Sidebar

Related Questions

This is a sequel to a related post which asked the eternal question: Can
This question is sort of a sequel to that question. When we want to
This question is a sequel to this question (I have applied the answer, but
Note: This is a sequel to my previous question about powersets. I have got
This is the sequel to this question . I would like to combine three
This past summer I was developing a basic ASP.NET/SQL Server CRUD app, and unit
This is almost identical to this question asked by another user, and is the
In a sequel question to this question , my corporate environment lacks the libpython2.6.so
This question is sequel of this one. So any idea how to decode this
This is a sequel question (on a different topic) to an earlier question .

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.