Friday, March 8, 2013
SQL abbreviated name from camel casing
/*
-- returns 'mtc' since the uppercase letters are M, T, C
select misc.fn_AbrvNameFromCamelCasing('MyTestCase')
*/
alter function misc.fn_AbrvNameFromCamelCasing(
@pString NVARCHAR(4000)
)
returns NVARCHAR(max)
as
begin
return (
SELECT
lower((
SELECT [text()]= ISNULL(q.Item, '')
FROM
(
select
cs.Item
from
dbo.fn_CharSplit4K(@pString) cs
where
cs.Item = upper(cs.Item) Collate SQL_Latin1_General_CP1_CS_AS
) q
FOR XML PATH('')
)) AS AbrvName
)
end
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment