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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:46:01+00:00 2026-05-27T22:46:01+00:00

Short to the point: I am using SQL Server Manager 2008 R2. I have

  • 0

Short to the point:

“I am using SQL Server Manager 2008 R2. I have a table with columns “product name” and “product size”. The size of the product is recorded in his name like that:

Ellas Kitchen Apple & Ginger Baby Cookies 120g

Ellas Kitchen Apple, Raisin ‘n’ Cinnamon Bakey Bakies 4 x 12g

Elastoplast Spray Plaster 32.5ml

Ellas Kitchen Stage 1 Butternut Squash Each

the size of this product should be:

120g

4 x 12g

32.5ml

N/A

(some of the products can have no size in there name and should be set to “N/A”)

I want to write T-SQL statement that update the product size getting it from the product name.

I have done this in javascript, but in order to do the things right I have to write SQL statement and that’s my problem. I have found it very difficult to work with “regular expressions” in T-SQL.

I have seen a exmaple of how to get only the number from string, but have no idea how to do using sql.

Declare @ProductName     varchar(100)
Select     @ProductName=    'dsadadsad15234Nudsadadmbers'

Select     @ProductName=    SubString(@ProductName,PATINDEX('%   [0-9]%',@ProductName),Len(@ProductName))
Select     @ProductName=    SubString(@ProductName,0,PATINDEX('%[^0-9]%',@ProductName))

Select     @ProductName

I will appreciate any example or idea.
Thanks, in advance.

EDIT:

Thanks for your reply,xQbert.

I have not included all possible formats, because if I have a working example with few of them I think I will be able to do for all. Anyway, in order to give more details here are the possible situations:

( Inumber + “x” + Dnumber + word)* + (_)* + (Dnumber + word)*
– * means 0 or more

where word can be – g, kg, ml, cl, pack
where Inumber is integer
where Dnumber is double
where _ is space

For exmaple:

12 x 100g
100ml
2 x kg

And the price (if there is ) is always in the end of the name:

Product name + product prize

For example:

Organix Organic Chick Pea & Red Pepper Lasagne 190g
Organix Organic Vegetable & Pork Risotto 250g
Organix Rice Cakes apple 50g
Organix Rusks 7m+ 6 Pack
Organix Savoury Biscuits Cheese & Onion Each
Organix Savoury Biscuits Tomato & Basil Each
Organix Stage 1 Squash & Chicken 2 x 120g

  • 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-27T22:46:01+00:00Added an answer on May 27, 2026 at 10:46 pm

    PATINDEX is not REGX and you have limited logic processing in TSQL compared to .NET. Have you condisidered CLR integration?

      http://msdn.microsoft.com/en-us/library/ms131089(SQL.100).aspx
    

    This from 2005 but and example of REGX in SQL via CLR integration.

      http://msdn.microsoft.com/en-us/library/ms345136(v=SQL.90).aspx
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a wonderful ASP.NET MVC 2 web application using MS SQL 2008 and
I have (what I think) is a simple SQL Server spatial query: Grab all
I have a couple of stored procedures on SQL Server 2005 that I've noticed
I've been using SQL Server to store historical time series data for a couple
I have a table with some 30 columns, already used in the application extensively.
Basically I have a sql 2005 standard server with a named instance installed (server/instance1).
This is a short question. At some point my thread understand that it should
Ok, I'll try and keep this short, sweet and to-the-point. We do massive GeoIP
we have a big portal that build using SharePoint 2007 , asp.net 3.5 ,
Without using dynamic SQL, and other than an If ELSE is there any way

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.