Hello ladies and gentlemen:
I have perused some solutions for my problem here but none work due to the uniqueness of my situation. First of all I am using this SQL version according to @@version:
Microsoft SQL Server 2012 (SP4-GDR) (KB4583465) – 11.0.7507.2 (X64) Nov 1 2020 00:48:37 Copyright (c) Microsoft Corporation Standard Edition (64-bit) on Windows NT 6.3 (Build 9600: ) (Hypervisor)
As the title says, I am trying to recreate the Oracle SQL InitCap() or the Excel Proper() function, but here are the system restrictions:
-I am using SQL Server 2012, so I cannot use newer functions such as String_Split.
-Very restricted environment does not let me use the CREATE functions, so no Functions, Procedures, etc.
It would need these features:
-Properly capitalize each first letter for each word in a string field while changing the rest to lower case, as most likely the whole string could be uppercase. Words that start with numbers (i.e. 234name) should capitalize the first letter (234Name).
-(Optional) Accommodate for company names with apostrophes, or words that start with “Mc” (i.e. MCDONALD should result in McDonald). Maybe have an IN() section where I can add more exceptions.
-(Nice to Have) Section that would allow me to specify stand alone exceptions such as “LLC” (When being a stand alone word that gets changed to “Llc”).
So I would need to the code to be included in a SELECT statement:
SELECT
NumericField1 AS “Number Field”,
(Smart Code Provided By StackOverFLow User(StringField1)) AS “Customer Name”,
…
FROM DataBase
Can this be accomplished?
Thanks in advance!
I have tried other options suggested here, but unfortunately I can not use functions (the CREATE command actually) and this environment uses Microsoft SQL Server 2012 (SP4-GDR) (KB4583465) – 11.0.7507.2 (X64), so I cannot use newer keywords that were also suggested.