<?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>TRY_PARSE &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/try_parse/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>Sat, 30 Sep 2017 06:22:07 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.6</generator>
	<item>
		<title>SQL Puzzle: SQL Advance Query &#8211; Check number is an Integer or not an Integer</title>
		<link>https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-check-number-is-an-integer-or-not-an-integer-try_parse/</link>
					<comments>https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-check-number-is-an-integer-or-not-an-integer-try_parse/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 22 Oct 2017 16:16:01 +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 Advance Query]]></category>
		<category><![CDATA[SQL Interview]]></category>
		<category><![CDATA[SQL Problem]]></category>
		<category><![CDATA[SQL Programming]]></category>
		<category><![CDATA[SQL Query]]></category>
		<category><![CDATA[SQL Tips and Tricks]]></category>
		<category><![CDATA[TRY_PARSE]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=6564</guid>

					<description><![CDATA[Check the below input data and expected output to check the number is an Integer or not an Integer. Input data: &#8216;1&#8217; Expected Output: [crayon-6ab55cc4e195e071993785/] Input data: &#8216;8a&#8217; Expected Output: [crayon-6ab55cc4e1961435019918/] Solution 1: [crayon-6ab55cc4e1962152123223/] Solution 2: Using TRY_PARSE [crayon-6ab55cc4e1963290627019/] 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%2F10%2Fsql-puzzle-sql-advance-query-check-number-is-an-integer-or-not-an-integer-try_parse%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Check%20number%20is%20an%20Integer%20or%20not%20an%20Integer" 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%2F10%2Fsql-puzzle-sql-advance-query-check-number-is-an-integer-or-not-an-integer-try_parse%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Check%20number%20is%20an%20Integer%20or%20not%20an%20Integer" 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%2F10%2Fsql-puzzle-sql-advance-query-check-number-is-an-integer-or-not-an-integer-try_parse%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Check%20number%20is%20an%20Integer%20or%20not%20an%20Integer" 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%2F10%2Fsql-puzzle-sql-advance-query-check-number-is-an-integer-or-not-an-integer-try_parse%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Check%20number%20is%20an%20Integer%20or%20not%20an%20Integer" 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%2F10%2Fsql-puzzle-sql-advance-query-check-number-is-an-integer-or-not-an-integer-try_parse%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Check%20number%20is%20an%20Integer%20or%20not%20an%20Integer" 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%2F10%2Fsql-puzzle-sql-advance-query-check-number-is-an-integer-or-not-an-integer-try_parse%2F&amp;linkname=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Check%20number%20is%20an%20Integer%20or%20not%20an%20Integer" 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%2F10%2Fsql-puzzle-sql-advance-query-check-number-is-an-integer-or-not-an-integer-try_parse%2F&#038;title=SQL%20Puzzle%3A%20SQL%20Advance%20Query%20%E2%80%93%20Check%20number%20is%20an%20Integer%20or%20not%20an%20Integer" data-a2a-url="https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-check-number-is-an-integer-or-not-an-integer-try_parse/" data-a2a-title="SQL Puzzle: SQL Advance Query – Check number is an Integer or not an Integer"></a></p><p>Check the below input data and expected output to check the number is an Integer or not an Integer. </p>
<p><strong>Input data: &#8216;1&#8217;</strong></p>
<p><strong>Expected Output:</strong></p>
<pre class="crayon-plain-tag">IsInteger
--------------
An Integer</pre> </p>
<p><strong>Input data: &#8216;8a&#8217;</strong><br />
<strong>Expected Output:</strong></p>
<pre class="crayon-plain-tag">IsInteger
--------------
Not an Integer</pre> </p>
<p><strong>Solution 1:</strong></p>
<pre class="crayon-plain-tag">DECLARE @str AS VARCHAR(10) = '1'
SELECT 
	CASE WHEN SUM(CASE WHEN ASCII(t) BETWEEN 48 AND 57 THEN 1 END) = SUM(1) 
	THEN 'An Integer' ELSE 'Not an Integer' END IsInteger
FROM
(
    SELECT DISTINCT SUBSTRING(@str,Number,1) t
    FROM Master..Spt_Values
    WHERE Number &gt; 0 AND Number &lt;= DATALENGTH(@str)
)t1
GO</pre> </p>
<p><strong>Solution 2: Using TRY_PARSE</strong></p>
<pre class="crayon-plain-tag">DECLARE @str AS VARCHAR(10) = '8a'
IF TRY_PARSE(@str AS INT) IS NULL
    SELECT 'Not an Integer' AS IsInteger
ELSE
    SELECT 'An Integer' AS IsInteger
GO</pre> </p>
<p><strong><code>Please try the different solution for this puzzle and share it via comment...</code></strong></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/10/sql-puzzle-sql-advance-query-check-number-is-an-integer-or-not-an-integer-try_parse/feed/</wfw:commentRss>
			<slash:comments>3</slash:comments>
		
		
			</item>
	</channel>
</rss>
