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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T01:59:47+00:00 2026-06-16T01:59:47+00:00

We have an issue with instrument names loaded into our data warehouse where they

  • 0

We have an issue with instrument names loaded into our data warehouse where they either loaded with the string all in upper case or in normal case (capital at the beginning of each word). We have a function that deals with changing all of the upper case strings into normal case and an example of some of these are below:

Merck & Co Inc Common Stock Usd.5
Newmont Mining Corp Common Stock Usd Inc 1.6

However there are parts of this which we would like to capitalise when it comes to reporting ie in the examples above ‘Usd’ should become ‘USD’, ‘Inc’ should become ‘INC’, ‘Corp’ should become ‘CORP’.

These are all held in a cross reference table, however i’m unsure of how i can update my select so that when i select my normal case instrument names it will check the cross reference table to ensure update(replace) the parts that should be capitalised into capitals.

I got as far as this:

CREATE TABLE capital ([InternalValue] VARCHAR(255), [ExternalValue] VARCHAR(255));

CREATE TABLE instrument ([Instrument] VARCHAR(255));

INSERT INTO capital ([InternalValue], [ExternalValue])
VALUES
('Usd', 'USD'),
('Ltd', 'LTD'),
('Corp', 'CORP'),
('Inc', 'INC')

INSERT INTO instrument ([Instrument])
VALUES
('Merck & Co Inc Common Stock Usd.5'),
('Newmont Mining Corp Common Stock Usd Inc 1.6');

SELECT REPLACE(Instrument, 'Usd', 'USD') FROM instrument AS i

But i don’t know how i can incorporate the capital table into this so that it can check the whole string for all possible capitalisations. Any help?

  • 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-16T01:59:48+00:00Added an answer on June 16, 2026 at 1:59 am

    If you have your values that you want to use as a replacement in a table able you are going to perform this action repeatedly, then you could create a function to perform the replacement:

    create function replacement(@string varchar(max))
    returns varchar(max)
    as
    begin
    
        with ReplaceWord(InternalWord, ExternalWord) as
        (
            select InternalValue, ExternalValue
            from capital
        )
        select @string =  REPLACE(@string, r.InternalWord, r.ExternalWord)
        from ReplaceWord r
        where CHARINDEX(r.InternalWord, @string) > 0
    
        return @string
    end
    

    Then to query the data you can use:

    SELECT dbo.replacement(i.Instrument) NewValue
    FROM instrument AS i
    

    See SQL Fiddle with Demo

    Which will return:

    |                                     NEWVALUE |
    ------------------------------------------------
    |            Merck & Co INC Common Stock USD.5 |
    | Newmont Mining CORP Common Stock USD INC 1.6 |
    

    Note: I found the base code here from @SQL Kiwi and altered it to use a function if this is something you will have to do on a consistent basis

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

Sidebar

Related Questions

I have an issue. I am getting data from a MySQL database, and make
I have this issue. I have a database of images in Core Data. I
I have an issue regarding freeing memory as under: string points; // some points
I have a data table the.data, where the first column indicate a measurement instrument,
I have issue with: <form:checkboxes path=roles cssClass=checkbox items=${roleSelections} /> If previous line is used
I have issue that is reproduced on g++. VC++ doesn't meet any problems. So
We are new to ROR, We have issue in creating Login/Logout process in ROR
Share your ideas please! I have issue to check the folder and convert a
Have an issue with marshall and unmarshall readers and writers. So here it is.
I have an issue with jquery and history.back(): I got a link: <a href=#

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.