<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
		>
<channel>
	<title>Comments on: SQL SERVER &#8211; Bad Practice of Using Keywords as an Object Name &#8211; Avoid Using Keywords as an Object</title>
	<atom:link href="http://blog.sqlauthority.com/2011/12/09/sql-server-bad-practice-of-using-keywords-as-an-object-name-avoid-using-keywords-as-an-object/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2011/12/09/sql-server-bad-practice-of-using-keywords-as-an-object-name-avoid-using-keywords-as-an-object/</link>
	<description>Personal Notes of Pinal Dave</description>
	<lastBuildDate>Fri, 17 May 2013 15:26:57 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
	<item>
		<title>By: SQLAuthority News &#8211; An Year Worth Remembering and Looking Forward to Better Next Year &#171; SQL Server Journey with SQLAuthority</title>
		<link>http://blog.sqlauthority.com/2011/12/09/sql-server-bad-practice-of-using-keywords-as-an-object-name-avoid-using-keywords-as-an-object/#comment-228854</link>
		<dc:creator><![CDATA[SQLAuthority News &#8211; An Year Worth Remembering and Looking Forward to Better Next Year &#171; SQL Server Journey with SQLAuthority]]></dc:creator>
		<pubDate>Sat, 31 Dec 2011 01:31:40 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=16261#comment-228854</guid>
		<description><![CDATA[[...] January: SQL SERVER – 2008 – Missing Index Script – Download and SQL SERVER – Copy Statistics from One Server to Another Server  February: SQL SERVER – Summary of Month – Wait Type – Day 28 of 28  March: SQL SERVER – ‘Denali’ – A Simple Example of Contained Databases  April: SQL SERVER – Introduction to SQL Azure – Creating Database and Connecting Database  May: SQL SERVER – Copy Database from Instance to Another Instance – Copy Paste in SQL Server  June: SQL SERVER – Solution – Puzzle – Statistics are not Updated but are Created Once  July:  SQL SERVER – Interview Questions and Answers – Frequently Asked Questions – Complete Downloadable List – Day 0 of 31  August: SQL SERVER – Tips from the SQL Joes 2 Pros Development Series – All about SQL Constraints – Day 22 of 35  September: SQL SERVER – Denali – Conversion Function – Difference between PARSE(), TRY_PARSE(), TRY_CONVERT()  October: SQL SERVER – Quick Note about JOIN – Common Questions and Simple Answers  November: SQL SERVER – Puzzle to Win Print Book – Functions FIRST_VALUE and LAST_VALUE with OVER clause and ORDER BY  December: SQL SERVER – Bad Practice of Using Keywords as an Object Name – Avoid Using Keywords as an Objec... [...]]]></description>
		<content:encoded><![CDATA[<p>[...] January: SQL SERVER – 2008 – Missing Index Script – Download and SQL SERVER – Copy Statistics from One Server to Another Server  February: SQL SERVER – Summary of Month – Wait Type – Day 28 of 28  March: SQL SERVER – ‘Denali’ – A Simple Example of Contained Databases  April: SQL SERVER – Introduction to SQL Azure – Creating Database and Connecting Database  May: SQL SERVER – Copy Database from Instance to Another Instance – Copy Paste in SQL Server  June: SQL SERVER – Solution – Puzzle – Statistics are not Updated but are Created Once  July:  SQL SERVER – Interview Questions and Answers – Frequently Asked Questions – Complete Downloadable List – Day 0 of 31  August: SQL SERVER – Tips from the SQL Joes 2 Pros Development Series – All about SQL Constraints – Day 22 of 35  September: SQL SERVER – Denali – Conversion Function – Difference between PARSE(), TRY_PARSE(), TRY_CONVERT()  October: SQL SERVER – Quick Note about JOIN – Common Questions and Simple Answers  November: SQL SERVER – Puzzle to Win Print Book – Functions FIRST_VALUE and LAST_VALUE with OVER clause and ORDER BY  December: SQL SERVER – Bad Practice of Using Keywords as an Object Name – Avoid Using Keywords as an Objec&#8230; [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: thomasrushton</title>
		<link>http://blog.sqlauthority.com/2011/12/09/sql-server-bad-practice-of-using-keywords-as-an-object-name-avoid-using-keywords-as-an-object/#comment-214161</link>
		<dc:creator><![CDATA[thomasrushton]]></dc:creator>
		<pubDate>Fri, 09 Dec 2011 18:05:17 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=16261#comment-214161</guid>
		<description><![CDATA[You can change the batch delimiter used by SSMS from &quot;GO&quot; to &quot;xyzzy&quot;, or &quot;8&quot;, or pretty much anything you want.  Jonathan @fatherjack Allen did a demo at SQLBits recently showing some of the weirdness that can happen if you set it to a number...

In SSMS, go to &quot;Tools&quot;, &quot;option&quot;, &quot;Query Execution&quot;, &quot;SQL Server&quot;.  And there you have the option to change the batch separator.  See http://msdn.microsoft.com/en-us/library/ms180280.aspx]]></description>
		<content:encoded><![CDATA[<p>You can change the batch delimiter used by SSMS from &#8220;GO&#8221; to &#8220;xyzzy&#8221;, or &#8220;8&#8243;, or pretty much anything you want.  Jonathan @fatherjack Allen did a demo at SQLBits recently showing some of the weirdness that can happen if you set it to a number&#8230;</p>
<p>In SSMS, go to &#8220;Tools&#8221;, &#8220;option&#8221;, &#8220;Query Execution&#8221;, &#8220;SQL Server&#8221;.  And there you have the option to change the batch separator.  See <a href="http://msdn.microsoft.com/en-us/library/ms180280.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ms180280.aspx</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Ashish Jain</title>
		<link>http://blog.sqlauthority.com/2011/12/09/sql-server-bad-practice-of-using-keywords-as-an-object-name-avoid-using-keywords-as-an-object/#comment-213995</link>
		<dc:creator><![CDATA[Ashish Jain]]></dc:creator>
		<pubDate>Fri, 09 Dec 2011 10:37:38 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=16261#comment-213995</guid>
		<description><![CDATA[Hi Pinal Sir,
                Very Informative post. 
                Thanks to you and DHall]]></description>
		<content:encoded><![CDATA[<p>Hi Pinal Sir,<br />
                Very Informative post.<br />
                Thanks to you and DHall</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: lalit</title>
		<link>http://blog.sqlauthority.com/2011/12/09/sql-server-bad-practice-of-using-keywords-as-an-object-name-avoid-using-keywords-as-an-object/#comment-213961</link>
		<dc:creator><![CDATA[lalit]]></dc:creator>
		<pubDate>Fri, 09 Dec 2011 08:58:36 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=16261#comment-213961</guid>
		<description><![CDATA[Really a nice observation as well fact.

Pinal , can we have an article on debuggin T-SQL in SSMS.
I am googling on it , but couldn&#039;t get any simpler article. I anticipate your&#039;s one will be of great help.

-Lalit]]></description>
		<content:encoded><![CDATA[<p>Really a nice observation as well fact.</p>
<p>Pinal , can we have an article on debuggin T-SQL in SSMS.<br />
I am googling on it , but couldn&#8217;t get any simpler article. I anticipate your&#8217;s one will be of great help.</p>
<p>-Lalit</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chirag Satasiya</title>
		<link>http://blog.sqlauthority.com/2011/12/09/sql-server-bad-practice-of-using-keywords-as-an-object-name-avoid-using-keywords-as-an-object/#comment-213892</link>
		<dc:creator><![CDATA[Chirag Satasiya]]></dc:creator>
		<pubDate>Fri, 09 Dec 2011 05:48:15 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=16261#comment-213892</guid>
		<description><![CDATA[Hi pinal sir,
thanks for the updates..
Useful and informative article..

Regard$
Chirag Satasiya]]></description>
		<content:encoded><![CDATA[<p>Hi pinal sir,<br />
thanks for the updates..<br />
Useful and informative article..</p>
<p>Regard$<br />
Chirag Satasiya</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Pankaj Nikam</title>
		<link>http://blog.sqlauthority.com/2011/12/09/sql-server-bad-practice-of-using-keywords-as-an-object-name-avoid-using-keywords-as-an-object/#comment-213878</link>
		<dc:creator><![CDATA[Pankaj Nikam]]></dc:creator>
		<pubDate>Fri, 09 Dec 2011 05:10:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=16261#comment-213878</guid>
		<description><![CDATA[Awesome Gotcha! Thanks for the repost.]]></description>
		<content:encoded><![CDATA[<p>Awesome Gotcha! Thanks for the repost.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2011/12/09/sql-server-bad-practice-of-using-keywords-as-an-object-name-avoid-using-keywords-as-an-object/#comment-213815</link>
		<dc:creator><![CDATA[pinaldave]]></dc:creator>
		<pubDate>Fri, 09 Dec 2011 04:03:47 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=16261#comment-213815</guid>
		<description><![CDATA[DHall,

Thank you for your comment. Your comment is much more informative and complete compared to original blog posts :)

Thanks for spending time and sharing this with us.

Good Learning and I will say again that I just learned!]]></description>
		<content:encoded><![CDATA[<p>DHall,</p>
<p>Thank you for your comment. Your comment is much more informative and complete compared to original blog posts :)</p>
<p>Thanks for spending time and sharing this with us.</p>
<p>Good Learning and I will say again that I just learned!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: DHall</title>
		<link>http://blog.sqlauthority.com/2011/12/09/sql-server-bad-practice-of-using-keywords-as-an-object-name-avoid-using-keywords-as-an-object/#comment-213797</link>
		<dc:creator><![CDATA[DHall]]></dc:creator>
		<pubDate>Fri, 09 Dec 2011 03:29:56 +0000</pubDate>
		<guid isPermaLink="false">http://blog.sqlauthority.com/?p=16261#comment-213797</guid>
		<description><![CDATA[The second point you make isn&#039;t exactly accurate. The semicolon has nothing (or very little) to do with executing the GO stored procedure. The code works the same even without the semicolon as long as EXEC and GO are on the same line or if [GO] is wrapped in square brackets.

However, if the GO proc name is the only thing (other than an optional comment) on the line following  following the EXEC command, then the SQL query window will try to interpret it as a batch delimiter if it&#039;s not followed by a semicolon or wrapped in square braces.

In other words, the following SQL will work as expected

INSERT INTO T1(ID) exec GO -- Note no semicolon
SELECT * FROM T1

-- and so will this:
INSERT INTO T1(ID) exec 
GO; -- Note the semicolon 
SELECT * FROM T1

-- and so will this:
INSERT INTO T1(ID) exec 
[GO] -- Note the square brackets but no semicolon 
SELECT * FROM T1

-- but this won&#039;t:

INSERT INTO T1(ID) exec 
GO -- Note no semicolon
SELECT * FROM T1

Another evidence that GO is different from SQL reserved word is to duplicate your experiment using [TABLE] as the proc name instead of GO. You&#039;ll note that unlike the word GO, the word TABLE must be wrapped in square brackets so that TSQL will allow it to be an object name. For GO, the square brackets are optional.

-- The following code works fine
CREATE PROCEDURE [TABLE]
AS SELECT 1 AS NUMBER
GO
INSERT INTO T1(ID) exec [TABLE] -- Note the square brackets
SELECT * FROM T1

-- but this generates a syntax error
CREATE PROCEDURE [TABLE]
AS SELECT 1 AS NUMBER
GO
INSERT INTO T1(ID) exec TABLE -- Note no square brackets
SELECT * FROM T1


As you mention in your first point, using keywords in this manner can be trouble, and should generally be avoided for many reasons, but it especially helps in this case to understand that GO is not a reserved word in TSQL, but only in some of the tools (like SSMS) that process SQL queries in batches.

The following excerpt from SQL BOL should help clarify the difference between the GO batch delimiter and true SQL reserved words.

GO is not a Transact-SQL statement; it is a command recognized by the sqlcmd and osql utilities and SQL Server Management Studio Code editor.

SQL Server utilities interpret GO as a signal that they should send the current batch of Transact-SQL statements to an instance of SQL Server. The current batch of statements is composed of all statements entered since the last GO, or since the start of the ad hoc session or script if this is the first GO. 

A Transact-SQL statement cannot occupy the same line as a GO command. However, the line can contain comments.]]></description>
		<content:encoded><![CDATA[<p>The second point you make isn&#8217;t exactly accurate. The semicolon has nothing (or very little) to do with executing the GO stored procedure. The code works the same even without the semicolon as long as EXEC and GO are on the same line or if [GO] is wrapped in square brackets.</p>
<p>However, if the GO proc name is the only thing (other than an optional comment) on the line following  following the EXEC command, then the SQL query window will try to interpret it as a batch delimiter if it&#8217;s not followed by a semicolon or wrapped in square braces.</p>
<p>In other words, the following SQL will work as expected</p>
<p>INSERT INTO T1(ID) exec GO &#8212; Note no semicolon<br />
SELECT * FROM T1</p>
<p>&#8211; and so will this:<br />
INSERT INTO T1(ID) exec<br />
GO; &#8212; Note the semicolon<br />
SELECT * FROM T1</p>
<p>&#8211; and so will this:<br />
INSERT INTO T1(ID) exec<br />
[GO] &#8212; Note the square brackets but no semicolon<br />
SELECT * FROM T1</p>
<p>&#8211; but this won&#8217;t:</p>
<p>INSERT INTO T1(ID) exec<br />
GO &#8212; Note no semicolon<br />
SELECT * FROM T1</p>
<p>Another evidence that GO is different from SQL reserved word is to duplicate your experiment using [TABLE] as the proc name instead of GO. You&#8217;ll note that unlike the word GO, the word TABLE must be wrapped in square brackets so that TSQL will allow it to be an object name. For GO, the square brackets are optional.</p>
<p>&#8211; The following code works fine<br />
CREATE PROCEDURE [TABLE]<br />
AS SELECT 1 AS NUMBER<br />
GO<br />
INSERT INTO T1(ID) exec [TABLE] &#8212; Note the square brackets<br />
SELECT * FROM T1</p>
<p>&#8211; but this generates a syntax error<br />
CREATE PROCEDURE [TABLE]<br />
AS SELECT 1 AS NUMBER<br />
GO<br />
INSERT INTO T1(ID) exec TABLE &#8212; Note no square brackets<br />
SELECT * FROM T1</p>
<p>As you mention in your first point, using keywords in this manner can be trouble, and should generally be avoided for many reasons, but it especially helps in this case to understand that GO is not a reserved word in TSQL, but only in some of the tools (like SSMS) that process SQL queries in batches.</p>
<p>The following excerpt from SQL BOL should help clarify the difference between the GO batch delimiter and true SQL reserved words.</p>
<p>GO is not a Transact-SQL statement; it is a command recognized by the sqlcmd and osql utilities and SQL Server Management Studio Code editor.</p>
<p>SQL Server utilities interpret GO as a signal that they should send the current batch of Transact-SQL statements to an instance of SQL Server. The current batch of statements is composed of all statements entered since the last GO, or since the start of the ad hoc session or script if this is the first GO. </p>
<p>A Transact-SQL statement cannot occupy the same line as a GO command. However, the line can contain comments.</p>
]]></content:encoded>
	</item>
</channel>
</rss>
