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 512087
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:17:02+00:00 2026-05-13T07:17:02+00:00

I have stored values in my database that look like 5XXXXXX , where X

  • 0

I have stored values in my database that look like 5XXXXXX, where X can be any digit. In other words, I need to match incoming SQL query strings like 5349878.

Does anyone have an idea how to do it?

I have different cases like XXXX7XX for example, so it has to be generic. I don’t care about representing the pattern in a different way inside the SQL Server.

I’m working with c# in .NET.

  • 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-13T07:17:02+00:00Added an answer on May 13, 2026 at 7:17 am

    stored value in DB is: 5XXXXXX [where x can be any digit]

    You don’t mention data types – if numeric, you’ll likely have to use CAST/CONVERT to change the data type to [n]varchar.

    Use:

    WHERE CHARINDEX(column, '5') = 1
      AND CHARINDEX(column, '.') = 0 --to stop decimals if needed
      AND ISNUMERIC(column) = 1
    

    References:

    • CHARINDEX
    • ISNUMERIC

    i have also different cases like XXXX7XX for example, so it has to be generic.

    Use:

    WHERE PATINDEX('%7%', column) = 5
      AND CHARINDEX(column, '.') = 0 --to stop decimals if needed
      AND ISNUMERIC(column) = 1
    

    References:

    • PATINDEX

    Regex Support

    SQL Server 2000+ supports regex, but the catch is you have to create the UDF function in CLR before you have the ability. There are numerous articles providing example code if you google them. Once you have that in place, you can use:

    • 5\d{6} for your first example
    • \d{4}7\d{2} for your second example

    For more info on regular expressions, I highly recommend this website.

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

Sidebar

Related Questions

I have table which contains double values stored in mysql database ...I need to
I have some YouTube URLs stored in a database that I need to rewrite.
Say I have a form that contains a drop-down list populated by values stored
I have a SQL Server 2008 database. This database has a stored procedure that
I have a form that submits values to database via Ajax and works fine
i have a data (in tabular form) that look like as follows 1 2
I have Hibernate Entities that look something like this (getters and setters left out):
I need to run a query that looks would look like INSERT INTO Appointments
I have a setting stored in database which has a value .jpg|.gif|.png . I
I have stored values in NsMutableDictionaries . ThenI stored all the dictionaries in NSMutable

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.