<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Triangle &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/triangle/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.dbrnd.com</link>
	<description>BIGData &#124; NoSQL &#124; MSSQL &#124; MySQL &#124; PostgreSQL</description>
	<lastBuildDate>Wed, 21 Jun 2017 20:21:46 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.5</generator>
	<item>
		<title>SQL Puzzle: SQL Advance Query &#8211; Draw a Triangle without using any Loop</title>
		<link>https://www.dbrnd.com/2017/06/sql-puzzle-sql-advance-query-draw-a-triangle-without-using-any-loop/</link>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sat, 17 Jun 2017 16:16:57 +0000</pubDate>
				<category><![CDATA[SQL Puzzle]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Administrator]]></category>
		<category><![CDATA[SQL Server Error]]></category>
		<category><![CDATA[SQL Server Monitoring]]></category>
		<category><![CDATA[SQL Server Performance Tuning]]></category>
		<category><![CDATA[SQL Server Programming]]></category>
		<category><![CDATA[SQL Server Tips and Tricks]]></category>
		<category><![CDATA[Triangle]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=5414</guid>

					<description><![CDATA[Check the below two solutions to draw a triangle without using any loop in SQL Server. Require Output: [crayon-6aad73f28a49f727031007/] Solution 1: [crayon-6aad73f28a4a2976463975/] Solution 2: Fetch number value from the MASTER..SPT_VALUES table of SQL Server. [crayon-6aad73f28a4a3505016708/] Please try the different solution for this puzzle and share it via comment...]]></description>
										<content:encoded><![CDATA[<p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fsql-puzzle-sql-advance-query-draw-a-triangle-without-using-any-loop%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Draw%20a%20Triangle%20without%20using%20any%20Loop" title="Facebook" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_twitter" href="https://www.addtoany.com/add_to/twitter?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fsql-puzzle-sql-advance-query-draw-a-triangle-without-using-any-loop%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Draw%20a%20Triangle%20without%20using%20any%20Loop" title="Twitter" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_linkedin" href="https://www.addtoany.com/add_to/linkedin?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fsql-puzzle-sql-advance-query-draw-a-triangle-without-using-any-loop%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Draw%20a%20Triangle%20without%20using%20any%20Loop" title="LinkedIn" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pinterest" href="https://www.addtoany.com/add_to/pinterest?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fsql-puzzle-sql-advance-query-draw-a-triangle-without-using-any-loop%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Draw%20a%20Triangle%20without%20using%20any%20Loop" title="Pinterest" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_reddit" href="https://www.addtoany.com/add_to/reddit?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fsql-puzzle-sql-advance-query-draw-a-triangle-without-using-any-loop%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Draw%20a%20Triangle%20without%20using%20any%20Loop" title="Reddit" rel="nofollow noopener" target="_blank"></a><a class="a2a_button_pocket" href="https://www.addtoany.com/add_to/pocket?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fsql-puzzle-sql-advance-query-draw-a-triangle-without-using-any-loop%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Draw%20a%20Triangle%20without%20using%20any%20Loop" title="Pocket" rel="nofollow noopener" target="_blank"></a><a class="a2a_dd addtoany_share_save addtoany_share" href="https://www.addtoany.com/share#url=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F06%2Fsql-puzzle-sql-advance-query-draw-a-triangle-without-using-any-loop%2F&#038;title=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Draw%20a%20Triangle%20without%20using%20any%20Loop" data-a2a-url="https://www.dbrnd.com/2017/06/sql-puzzle-sql-advance-query-draw-a-triangle-without-using-any-loop/" data-a2a-title="SQL Puzzle: SQL Advance Query – Draw a Triangle without using any Loop"></a></p><p>Check the below two solutions to draw a triangle without using any loop in SQL Server.</p>
<p><strong>Require Output:</strong></p>
<pre class="crayon-plain-tag">Triangle
----------
*
**
***
****
*****</pre> </p>
<p><strong>Solution 1:</strong></p>
<pre class="crayon-plain-tag">declare @star varchar(10) = '*';
declare @num int = 5;
 
; with StarCTE as
(
	select cast(@star as varchar(10)) as Triangle, 1 as cnt
	union all
	select cast((Triangle+@star) as varchar(10)) as Triangle, cnt+1 as cnt
	from StarCTE
	where cnt &lt; @num
)
select Triangle from StarCTE</pre> </p>
<p><strong>Solution 2:</strong> Fetch number value from the MASTER..SPT_VALUES table of SQL Server.</p>
<pre class="crayon-plain-tag">SELECT REPLICATE(Star,number) Triangle FROM ( SELECT '*' Star ) b
CROSS APPLY
(
	SELECT DISTINCT number
	FROM
	   MASTER..SPT_VALUES
	WHERE number &gt; 0 and number &lt; 6
) as T</pre> </p>
<p><strong><code>Please try the different solution for this puzzle and share it via comment...</code></strong></p>
]]></content:encoded>
					
		
		
			</item>
	</channel>
</rss>
