<?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>Prevent SELECT * &#8211; Database Research &amp; Development</title>
	<atom:link href="https://www.dbrnd.com/tag/prevent-select/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>Mon, 02 Apr 2018 19:42:25 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=7.0.4</generator>
	<item>
		<title>SQL Server Interview: How to prevent &#8216;SELECT *&#8217; using T-SQL Script?</title>
		<link>https://www.dbrnd.com/2017/02/sql-server-interview-how-to-prevent-select-using-t-sql-script-select-all-column/</link>
					<comments>https://www.dbrnd.com/2017/02/sql-server-interview-how-to-prevent-select-using-t-sql-script-select-all-column/#comments</comments>
		
		<dc:creator><![CDATA[Anvesh Patel]]></dc:creator>
		<pubDate>Sun, 19 Feb 2017 16:16:56 +0000</pubDate>
				<category><![CDATA[SQL Server]]></category>
		<category><![CDATA[SQL Server Interview]]></category>
		<category><![CDATA[Anvesh Patel]]></category>
		<category><![CDATA[database]]></category>
		<category><![CDATA[database research and development]]></category>
		<category><![CDATA[dbrnd]]></category>
		<category><![CDATA[Prevent SELECT *]]></category>
		<category><![CDATA[select]]></category>
		<category><![CDATA[SELECT ALL Column]]></category>
		<category><![CDATA[SQL Query]]></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[t-sql interview]]></category>
		<category><![CDATA[TSQL]]></category>
		<guid isPermaLink="false">https://www.dbrnd.com/?p=4581</guid>

					<description><![CDATA[<div><img width="368" height="336" src="https://www.dbrnd.com/wp-content/uploads/2017/02/Anvesh-2-min.jpg" class="attachment-post-image size-post-image wp-post-image" alt="Anvesh (2)-min" decoding="async" fetchpriority="high" /></div>Guys, Don&#8217;t surprise with this question. If you are in front of me, surely I will ask this question in an interview. I know, most of you are using &#8216;SELECT *&#8217; in T-SQL code. I already shared an article on &#8216;SELECT *&#8217; to be good or bad. SELECT all columns to be good or bad [&#8230;]]]></description>
										<content:encoded><![CDATA[<div><img width="368" height="336" src="https://www.dbrnd.com/wp-content/uploads/2017/02/Anvesh-2-min.jpg" class="attachment-post-image size-post-image wp-post-image" alt="Anvesh (2)-min" decoding="async" /></div><p><a class="a2a_button_facebook" href="https://www.addtoany.com/add_to/facebook?linkurl=https%3A%2F%2Fwww.dbrnd.com%2F2017%2F02%2Fsql-server-interview-how-to-prevent-select-using-t-sql-script-select-all-column%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20prevent%20%E2%80%98SELECT%20%2A%E2%80%99%20using%20T-SQL%20Script%3F" 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%2F02%2Fsql-server-interview-how-to-prevent-select-using-t-sql-script-select-all-column%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20prevent%20%E2%80%98SELECT%20%2A%E2%80%99%20using%20T-SQL%20Script%3F" 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%2F02%2Fsql-server-interview-how-to-prevent-select-using-t-sql-script-select-all-column%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20prevent%20%E2%80%98SELECT%20%2A%E2%80%99%20using%20T-SQL%20Script%3F" 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%2F02%2Fsql-server-interview-how-to-prevent-select-using-t-sql-script-select-all-column%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20prevent%20%E2%80%98SELECT%20%2A%E2%80%99%20using%20T-SQL%20Script%3F" 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%2F02%2Fsql-server-interview-how-to-prevent-select-using-t-sql-script-select-all-column%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20prevent%20%E2%80%98SELECT%20%2A%E2%80%99%20using%20T-SQL%20Script%3F" 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%2F02%2Fsql-server-interview-how-to-prevent-select-using-t-sql-script-select-all-column%2F&amp;linkname=SQL%20Server%20Interview%3A%20How%20to%20prevent%20%E2%80%98SELECT%20%2A%E2%80%99%20using%20T-SQL%20Script%3F" 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%2F02%2Fsql-server-interview-how-to-prevent-select-using-t-sql-script-select-all-column%2F&#038;title=SQL%20Server%20Interview%3A%20How%20to%20prevent%20%E2%80%98SELECT%20%2A%E2%80%99%20using%20T-SQL%20Script%3F" data-a2a-url="https://www.dbrnd.com/2017/02/sql-server-interview-how-to-prevent-select-using-t-sql-script-select-all-column/" data-a2a-title="SQL Server Interview: How to prevent ‘SELECT *’ using T-SQL Script?"></a></p><p><em>Guys, Don&#8217;t surprise with this question. If you are in front of me, surely I will ask this question in an interview. I know, most of you are using &#8216;SELECT *&#8217; in T-SQL code. </em></p>
<p>I already shared an article on &#8216;SELECT *&#8217; to be good or bad.</p>
<blockquote class="wp-embedded-content" data-secret="PdfM9S9wQa"><p><a href="https://www.dbrnd.com/2015/09/select-all-columns-to-be-good-or-bad-in-database-system/">SELECT all columns to be good or bad in database system</a></p></blockquote>
<p><iframe class="wp-embedded-content" sandbox="allow-scripts" security="restricted"  src="https://www.dbrnd.com/2015/09/select-all-columns-to-be-good-or-bad-in-database-system/embed/#?secret=PdfM9S9wQa" data-secret="PdfM9S9wQa" width="600" height="338" title="&#8220;SELECT all columns to be good or bad in database system&#8221; &#8212; Database Research &amp; Development" frameborder="0" marginwidth="0" marginheight="0" scrolling="no"></iframe></p>
<p><strong>Regarding database coding standard, I am always strict and even I never allow single extra space in T-SQL Code.</strong></p>
<p>Let me share my experience,</p>
<blockquote><p>In my group, I already set guidelines like &#8216;do not use SELECT *&#8217;, but then also I found total 320 &#8216;SELECT *&#8217; statements out of 2125 statements in our project.</p></blockquote>
<blockquote><p>The Developers are always running with their practice, but as DB Professionals we must prevent SELECT *.</p></blockquote>
<blockquote><p>When I found these bad queries, and I didn&#8217;t react immediately. I had been waiting for tight deadlines. Before a month ago I scheduled an internal demonstration.</p></blockquote>
<blockquote><p>On this occasion, I planned the penalty for those developers who wrote &#8216;SELECT *&#8217; in their stored procedures.</p>
<p>In the morning, I added one extra overnight computed column on those tables. The computed column was (BadSelect AS (1 / 0)), that means if anyone is selecting data using &#8216;SELECT *&#8217;, they get error like &#8216;Divide by zero error encountered&#8217; and fails the execution of a query.</p></blockquote>
<blockquote><p>Now after this alteration, developers had removed all &#8216;SELECT *&#8217; and we started our demonstration late by 3 hours.</p></blockquote>
<blockquote><p>It is OK for me, but next time they will never put &#8216;SELECT *&#8217; in T-SQL Code.</p></blockquote>
<p>Use below demonstration, to test this exercise and prepare yourself for this kind of interview questions as well.</p>
<p><strong>Generate a script to add computed column in all the table:</strong><br />
You can copy script for requiring a table and can create computed column.<br />
<pre class="crayon-plain-tag">SELECT 'ALTER TABLE ' + name + ' ADD BadSelect AS (1 / 0) 
GO'
FROM sys.tables</pre>
<p><strong>If developer execute &#8216;SELECT *&#8217;, they will get a bellow error:</strong><br />
<pre class="crayon-plain-tag">Msg 8134, Level 16, State 1, Line 1
Divide by zero error encountered.</pre>
<p><strong>Generate a script to remove computed column from all the table:</strong><br />
<pre class="crayon-plain-tag">SELECT 'ALTER TABLE ' + name + ' DROP COLUMN BadSelect 
GO'
FROM sys.tables</pre>
]]></content:encoded>
					
					<wfw:commentRss>https://www.dbrnd.com/2017/02/sql-server-interview-how-to-prevent-select-using-t-sql-script-select-all-column/feed/</wfw:commentRss>
			<slash:comments>9</slash:comments>
		
		
			</item>
	</channel>
</rss>
