Methods 如何在SAP HANA中将每个单词的第一个字母作为大写字母

Methods 如何在SAP HANA中将每个单词的第一个字母作为大写字母,methods,hana,capitalization,Methods,Hana,Capitalization,我们有没有办法将每个单词的第一个字母作为SAP HANA中某列的大写字母 i、 e从“提问”到“提问”来自: 使用它: 'string'.capitalizeFirstLetter() 可能给你一个线索?我不熟悉SAP HANA,但您可能可以将其标记为标题句,并对其进行案例规范化 在T-SQL中,您可以执行以下操作: SELECT UPPER(LEFT(ColumnA,1))+LOWER(RIGHT(ColumnA,(LEN(ColumnA)-1))) FROM Table1; 您告诉DB

我们有没有办法将每个单词的第一个字母作为SAP HANA中某列的大写字母

i、 e从“提问”到“提问”

来自:

使用它:

'string'.capitalizeFirstLetter() 
可能给你一个线索?我不熟悉SAP HANA,但您可能可以将其标记为标题句,并对其进行案例规范化

T-SQL
中,您可以执行以下操作:

SELECT
UPPER(LEFT(ColumnA,1))+LOWER(RIGHT(ColumnA,(LEN(ColumnA)-1)))
FROM Table1;
您告诉DBMS将第一个字母用大写,其余字符串用小写。之所以需要
LEN
,是因为我假设字符串的长度不是静态的,并且在脚本中它是动态处理的。
+
在其他方言中是CONCAT。关于A列中的空格和you列中第二个或更多单词的大写,我正在尝试Michael Valentine Jones在2006年12月1日描述的一些东西,另请参见下面的部分代码。我一弄明白这件事就回到这件事上来。我还不确定UNIONALLSELECT语句是如何工作的。将需要几天时间(由于周末)。不管怎样,也许这对你有帮助。将“,”替换为“”或其他内容

-- Create temp table to test inserting values into
create table #t (num int)

-- Create a comma delimited string to test with
declare @str    varchar(500)
select @str = '4,2,7,7834,45,24,45,77'

--------------------------------------------------------
---- Code to load the delimited string into a table ----
--------------------------------------------------------

-- Create insert for comma delimited values
declare @sql varchar(8000)
select @sql = 'insert into #t select '+ replace(@str,',',' union all select ')

-- Load values from comma delimited string into a table
exec ( @sql )

在SQL级别上没有用于该操作的内置函数。
不过,您可以编写一个用户定义的函数来实现这一点。

我发现了一段
T-SQL
脚本,该脚本创建了一个
函数
“ProperCase”,它将通过在select语句中调用函数来实现这一目的。看看下面。我在这里找到它:(作者:jsmith8858)

创建函数ProperCase(@Text作为varchar(8000))
返回varchar(8000)
作为
开始
声明@Reset位;
声明@Ret varchar(8000);
声明@i int;
声明@c字符(1);
选择@Reset=1、@i=1、@Ret='';

而(@i对于HANA 2 SPS3,有一个内置函数称为“Initcap”

-- Create temp table to test inserting values into
create table #t (num int)

-- Create a comma delimited string to test with
declare @str    varchar(500)
select @str = '4,2,7,7834,45,24,45,77'

--------------------------------------------------------
---- Code to load the delimited string into a table ----
--------------------------------------------------------

-- Create insert for comma delimited values
declare @sql varchar(8000)
select @sql = 'insert into #t select '+ replace(@str,',',' union all select ')

-- Load values from comma delimited string into a table
exec ( @sql )
create function ProperCase(@Text as varchar(8000))
returns varchar(8000)
as
begin
   declare @Reset bit;
   declare @Ret varchar(8000);
   declare @i int;
   declare @c char(1);

   select @Reset = 1, @i=1, @Ret = '';

   while (@i <= len(@Text))
    select @c= substring(@Text,@i,1),
               @Ret = @Ret + case when @Reset=1 then UPPER(@c) else LOWER(@c) end,
               @Reset = case when @c like '[a-zA-Z]' then 0 else 1 end,
               @i = @i +1
   return @Ret
end
SELECT INITCAP('that''s a new function') FROM DUMMY;

That'S A New Function