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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T10:55:36+00:00 2026-06-04T10:55:36+00:00

I have two tables with the following information : Products Name | ID |

  • 0

I have two tables with the following information :

Products

Name  |    ID   |   

Name contains a short string indicating the name, and language of the row.

Languages

Language   |   ID   |

Language would be the same substring contained within the Name column above.

What I would like to do is add a column to my Products table called LanguageID.

I would then extract the substring indicating the language from the Name column, and do a case-insensitive comparison to the Language column in the Languages table. Where a match is found, I would like to insert the ID value from the Languages table into the newly created LanguageID column, creating a foreign key relationship.

So, for example in my Products Table, I have :

Name                  |   ID
Product 1 - enGlIsh   |   1

In my Languages table, I have :

Language    |   ID
English     |   77

So what I would like to end up with in my Products table is :

Name                   |   ID   |   LanguageID
Product 1 - enGlIsh    |   1    |    77

I have written a regEx to return the Language from my substring, I am not sure how I can use it and structure this query in SQL server, however. How can I do this ?

Here is the Regex :

Regex regEx = new Regex(@"(.+\s*-\s*.+\s*-\s*.+)\s*-\s*(\w{1,3}\s*-\s*\w{1,3})\s*-\s*.+");
                string language = regEx.Match(   NAME   ).Groups[2].Value.ToString(); 
  • 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-04T10:55:37+00:00Added an answer on June 4, 2026 at 10:55 am

    No need for a regexp;

    create table Languages(id int identity(1,1), language varchar(32) )
    

    Get a list of languages (assumes the format is <anything><space><language_name>):

    insert Languages
        select distinct 
           right(name,charindex(' ', reverse(name), 1)-1) as [language]
        from products
    

    Then you can go back and replace/update as needed using the same expression to get the language name.

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

Sidebar

Related Questions

I have two tables: Accounts , which contains the information of accounts that a
I have two tables, DH_MASTER and DH_ALIAS . DH_MASTER contains information about a person,
I have two tables that contain the following information models id manufactor 1 Mercedes
I have two tables in my database as following: Employee Table: Username, Name, Job,
I have following two tables (student and marks): In student table I have information
I have two tables with the following (simplified) structures: table "Factors" which holds data
I am using VB.NET with LINQ to MS SQL. I have two following tables.
I have two tables t1 and t2 as following t1 A B C D
I have two database tables with the following structure: actions: action_id int(11) primary key
I have two tables that I am joining with the following query... select *

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.