<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	
	>
<channel>
	<title>
	Comments on: SQL Puzzle: SQL Advance Query – Create a function to get the string in InitCap Format	</title>
	<atom:link href="https://www.dbrnd.com/2017/11/sql-puzzle-create-a-function-to-get-the-string-in-initcap-format/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com/2017/11/sql-puzzle-create-a-function-to-get-the-string-in-initcap-format/</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Thu, 24 Oct 2019 12:37:21 +0000</lastBuildDate>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>
		By: Samrat		</title>
		<link>https://www.dbrnd.com/2017/11/sql-puzzle-create-a-function-to-get-the-string-in-initcap-format/#comment-7838</link>

		<dc:creator><![CDATA[Samrat]]></dc:creator>
		<pubDate>Thu, 24 Oct 2019 12:37:21 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6072#comment-7838</guid>

					<description><![CDATA[CREATE FUNCTION InitCap(@Value VARCHAR(2000))
RETURNS VARCHAR(2000)
AS
BEGIN
DECLARE @R_VALUE VARCHAR(2000)=&#039;&#039;

SELECT @R_VALUE+=STRING_AGG(UPPER(SUBSTRING(VALUE,1,1))+LOWER(SUBSTRING(VALUE,2,LEN(VALUE))),&#039; &#039;)
FROM STRING_SPLIT(@Value,&#039; &#039;)

RETURN @R_VALUE
END]]></description>
			<content:encoded><![CDATA[<p>CREATE FUNCTION InitCap(@Value VARCHAR(2000))<br />
RETURNS VARCHAR(2000)<br />
AS<br />
BEGIN<br />
DECLARE @R_VALUE VARCHAR(2000)=&#8221;</p>
<p>SELECT @R_VALUE+=STRING_AGG(UPPER(SUBSTRING(VALUE,1,1))+LOWER(SUBSTRING(VALUE,2,LEN(VALUE))),&#8217; &#8216;)<br />
FROM STRING_SPLIT(@Value,&#8217; &#8216;)</p>
<p>RETURN @R_VALUE<br />
END</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: sqlguru		</title>
		<link>https://www.dbrnd.com/2017/11/sql-puzzle-create-a-function-to-get-the-string-in-initcap-format/#comment-7500</link>

		<dc:creator><![CDATA[sqlguru]]></dc:creator>
		<pubDate>Sun, 14 Jul 2019 06:43:02 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6072#comment-7500</guid>

					<description><![CDATA[create function dbo.fn_GetInitCap(@inputStr varchar(255)) returns varchar(255) as
begin
	declare @newstr varchar(255);


	set @inputStr  = replace(@inputStr, &#039; &#039;,&#039;~&#039;);
	with cte as (
		select @inputStr inpt, cast(&#039;&#039; as varchar(255)) items
		union all
		select cast(stuff(inpt,1,iif(PATINDEX(&#039;%[^a-zA-Z]%&#039;,inpt) &#062; 0, PATINDEX(&#039;%[^a-zA-Z]%&#039;,inpt),len(inpt) ),&#039;&#039;) as varchar(255)), substring(inpt, 1, iif(PATINDEX(&#039;%[^a-zA-Z]%&#039;,inpt) &#062; 0, PATINDEX(&#039;%[^a-zA-Z]%&#039;,inpt),len(inpt) )) from cte where inpt  &#039;&#039;
	) --select * from cte;
	, cte2 as(
		select items, row_number() over (order by (select null)) rn
		from cte
		where items  &#039;&#039;
	) --select * from cte2;
	, cte3 as(
		select items, rn, cast(&#039;&#039; as varchar(1)) ltr, 0 idx from cte2
		union all
		select stuff(items,1,1,&#039;&#039;), rn, substring(items,1,1), idx + 1 from cte3 where items  &#039;&#039;
	)
	select @newstr = replace(
	(select ltr2+&#039;&#039; from (
	select cte3.*, iif(idx=1, upper(ltr),lower(ltr)) ltr2 from cte3 
	where ltr  &#039;&#039;
	--order by rn, idx
	) t order by rn, idx for xml path(&#039;&#039;)),&#039;~&#039;,&#039; &#039;);

	return @newstr;
	

end
go

select dbo.fn_GetInitCap(&#039;Hi I Am Anvesh Patel Owner Of Dbrnd.Com&#039;);]]></description>
			<content:encoded><![CDATA[<p>create function dbo.fn_GetInitCap(@inputStr varchar(255)) returns varchar(255) as<br />
begin<br />
	declare @newstr varchar(255);</p>
<p>	set @inputStr  = replace(@inputStr, &#8216; &#8216;,&#8217;~&#8217;);<br />
	with cte as (<br />
		select @inputStr inpt, cast(&#8221; as varchar(255)) items<br />
		union all<br />
		select cast(stuff(inpt,1,iif(PATINDEX(&#8216;%[^a-zA-Z]%&#8217;,inpt) &gt; 0, PATINDEX(&#8216;%[^a-zA-Z]%&#8217;,inpt),len(inpt) ),&#8221;) as varchar(255)), substring(inpt, 1, iif(PATINDEX(&#8216;%[^a-zA-Z]%&#8217;,inpt) &gt; 0, PATINDEX(&#8216;%[^a-zA-Z]%&#8217;,inpt),len(inpt) )) from cte where inpt  &#8221;<br />
	) &#8211;select * from cte;<br />
	, cte2 as(<br />
		select items, row_number() over (order by (select null)) rn<br />
		from cte<br />
		where items  &#8221;<br />
	) &#8211;select * from cte2;<br />
	, cte3 as(<br />
		select items, rn, cast(&#8221; as varchar(1)) ltr, 0 idx from cte2<br />
		union all<br />
		select stuff(items,1,1,&#8221;), rn, substring(items,1,1), idx + 1 from cte3 where items  &#8221;<br />
	)<br />
	select @newstr = replace(<br />
	(select ltr2+&#8221; from (<br />
	select cte3.*, iif(idx=1, upper(ltr),lower(ltr)) ltr2 from cte3<br />
	where ltr  &#8221;<br />
	&#8211;order by rn, idx<br />
	) t order by rn, idx for xml path(&#8221;)),&#8217;~&#8217;,&#8217; &#8216;);</p>
<p>	return @newstr;</p>
<p>end<br />
go</p>
<p>select dbo.fn_GetInitCap(&#8216;Hi I Am Anvesh Patel Owner Of Dbrnd.Com&#8217;);</p>
]]></content:encoded>
		
			</item>
		<item>
		<title>
		By: Ashutosh Srivastava		</title>
		<link>https://www.dbrnd.com/2017/11/sql-puzzle-create-a-function-to-get-the-string-in-initcap-format/#comment-6111</link>

		<dc:creator><![CDATA[Ashutosh Srivastava]]></dc:creator>
		<pubDate>Fri, 05 Jan 2018 06:08:12 +0000</pubDate>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6072#comment-6111</guid>

					<description><![CDATA[HI Avnesh, Thanks for your explanation. I have one situation i.e. There is one column where 100 records are available. Value is like accountnumber, subaccountnumber etc. I need an output like: Account_Number, Sub_Account_Number.

Could you please help me regarding this.

Regards,
Ashutosh Srivastava]]></description>
			<content:encoded><![CDATA[<p>HI Avnesh, Thanks for your explanation. I have one situation i.e. There is one column where 100 records are available. Value is like accountnumber, subaccountnumber etc. I need an output like: Account_Number, Sub_Account_Number.</p>
<p>Could you please help me regarding this.</p>
<p>Regards,<br />
Ashutosh Srivastava</p>
]]></content:encoded>
		
			</item>
	</channel>
</rss>
