<?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; Guidelines and Coding Standards Part &#8211; 1</title>
	<atom:link href="http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/</link>
	<description>Notes of a SQL Server MVP and Database Administrator</description>
	<lastBuildDate>Sat, 21 Nov 2009 05:54:09 +0000</lastBuildDate>
	<generator>http://wordpress.com/</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Pol28</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-56913</link>
		<dc:creator>Pol28</dc:creator>
		<pubDate>Thu, 22 Oct 2009 19:27:05 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-56913</guid>
		<description>With the current there is a   rise in the number of facilities and a decrease in funding and staffing   in the Air Inspections Program. ,</description>
		<content:encoded><![CDATA[<p>With the current there is a   rise in the number of facilities and a decrease in funding and staffing   in the Air Inspections Program. ,</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bharat Shah</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-56577</link>
		<dc:creator>Bharat Shah</dc:creator>
		<pubDate>Sat, 10 Oct 2009 12:24:28 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-56577</guid>
		<description>hello sir,

Can u send me the complete reference of &#039;CREATE INDEX&#039; which session was taken by u on 3rd october.

You have announced that, if anybody will send me request me
i will send the  comepete reference of &#039;CREATE INDEX&#039; with Examples.</description>
		<content:encoded><![CDATA[<p>hello sir,</p>
<p>Can u send me the complete reference of &#8216;CREATE INDEX&#8217; which session was taken by u on 3rd october.</p>
<p>You have announced that, if anybody will send me request me<br />
i will send the  comepete reference of &#8216;CREATE INDEX&#8217; with Examples.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Bill Gibbs</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-54270</link>
		<dc:creator>Bill Gibbs</dc:creator>
		<pubDate>Thu, 30 Jul 2009 13:54:51 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-54270</guid>
		<description>sorry for late response, but this is an interesting thread.  as for prefixes, they are used in most environments and help to keep things consistent, because when you are calling sp from application code, the prefix really helps...and for user sp, usp_ does the trick.  also, yay Schemas! having to work on DBs where 1000s of tables are dumped together, and you have to figure out how they relate and what the logical groupings are, Shemas are a great underused way to manage this.</description>
		<content:encoded><![CDATA[<p>sorry for late response, but this is an interesting thread.  as for prefixes, they are used in most environments and help to keep things consistent, because when you are calling sp from application code, the prefix really helps&#8230;and for user sp, usp_ does the trick.  also, yay Schemas! having to work on DBs where 1000s of tables are dumped together, and you have to figure out how they relate and what the logical groupings are, Shemas are a great underused way to manage this.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Alex Romanov</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-52943</link>
		<dc:creator>Alex Romanov</dc:creator>
		<pubDate>Thu, 11 Jun 2009 14:30:25 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-52943</guid>
		<description>Microsoft does not reccomend using sp prefix for stored procedures because it is alreday used by system stored procs and user defined proc  with sp in it will have additional overhead during name complie process</description>
		<content:encoded><![CDATA[<p>Microsoft does not reccomend using sp prefix for stored procedures because it is alreday used by system stored procs and user defined proc  with sp in it will have additional overhead during name complie process</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-48534</link>
		<dc:creator>Brian Tkatch</dc:creator>
		<pubDate>Mon, 09 Mar 2009 14:01:47 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-48534</guid>
		<description>The SET NOCOUNT link should probably point o http://blog.sqlauthority.com/2007/04/28/sql-server-good-better-and-best-programming-techniques/comment-page-1/ where he says: &quot;Remember to SET NOCOUNT ON at the beginning of your SQL bataches, stored procedures, triggers to avoid network traffic. This will also reduct the chances of error on linked server.&quot;</description>
		<content:encoded><![CDATA[<p>The SET NOCOUNT link should probably point o <a href="http://blog.sqlauthority.com/2007/04/28/sql-server-good-better-and-best-programming-techniques/comment-page-1/" rel="nofollow">http://blog.sqlauthority.com/2007/04/28/sql-server-good-better-and-best-programming-techniques/comment-page-1/</a> where he says: &#8220;Remember to SET NOCOUNT ON at the beginning of your SQL bataches, stored procedures, triggers to avoid network traffic. This will also reduct the chances of error on linked server.&#8221;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Brian Tkatch</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-48532</link>
		<dc:creator>Brian Tkatch</dc:creator>
		<pubDate>Mon, 09 Mar 2009 13:53:16 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-48532</guid>
		<description>&quot;The table is Customers (with the s, becuase that is what is in the table as a whole, the customers)&quot;

That is not how i see it at all. The TABLE merely defines the records within it, which each are, individually, one customer.</description>
		<content:encoded><![CDATA[<p>&#8220;The table is Customers (with the s, becuase that is what is in the table as a whole, the customers)&#8221;</p>
<p>That is not how i see it at all. The TABLE merely defines the records within it, which each are, individually, one customer.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Michael</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-48288</link>
		<dc:creator>Michael</dc:creator>
		<pubDate>Fri, 06 Mar 2009 22:34:32 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-48288</guid>
		<description>I think that by adding sp to a stored procedure the sql engine looks first in the master db for the stored procedure.

I do not like any prefixes - name stored procedures based on the table/object they most affect and what they do based on CRUD

CustomerGet (get one customer)
CustomerSelect (get more than one customer)
CustomerUpdate
CustomerAdd
CustomerDelete

The table is Customers (with the s, becuase that is what is in the table as a whole, the customers)

a view that joins between Customers and Accounts and groups on customer (where a customer can have more than one account). Since Customer is the group by it is listed first in the name

CustomersAccounts

Accounts and Customers listed by account, since account is the group by it is listed first in the name

AccountsCustomers</description>
		<content:encoded><![CDATA[<p>I think that by adding sp to a stored procedure the sql engine looks first in the master db for the stored procedure.</p>
<p>I do not like any prefixes &#8211; name stored procedures based on the table/object they most affect and what they do based on CRUD</p>
<p>CustomerGet (get one customer)<br />
CustomerSelect (get more than one customer)<br />
CustomerUpdate<br />
CustomerAdd<br />
CustomerDelete</p>
<p>The table is Customers (with the s, becuase that is what is in the table as a whole, the customers)</p>
<p>a view that joins between Customers and Accounts and groups on customer (where a customer can have more than one account). Since Customer is the group by it is listed first in the name</p>
<p>CustomersAccounts</p>
<p>Accounts and Customers listed by account, since account is the group by it is listed first in the name</p>
<p>AccountsCustomers</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mi mi</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-43486</link>
		<dc:creator>mi mi</dc:creator>
		<pubDate>Fri, 03 Oct 2008 18:20:26 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-43486</guid>
		<description>just to bring it to your attention that &quot;Read More&quot; link regarding SET NOCOUNT ON  is pointing to &quot;SQL SERVER - Simple Cursor to Select Tables in Database with Static Prefix and Date Created&quot; page.</description>
		<content:encoded><![CDATA[<p>just to bring it to your attention that &#8220;Read More&#8221; link regarding SET NOCOUNT ON  is pointing to &#8220;SQL SERVER &#8211; Simple Cursor to Select Tables in Database with Static Prefix and Date Created&#8221; page.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Sinix</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-43415</link>
		<dc:creator>Sinix</dc:creator>
		<pubDate>Wed, 01 Oct 2008 00:58:05 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-43415</guid>
		<description>&gt; If you have big subset of table group than it makes sense to give prefix for this table group. Prefix should be separated by _. 

&gt; Use following naming convention for Stored Procedure. sp_[_] Where action is: Get, Delete, Update, Write, Archive, Insert… i.e. verb 

Use SCHEMAs, Luke :)

I&#039;d like to see good old approach &quot;fit all that info in that damn short name&quot;. But I&#039;ll not be happy if I find it in our projects. Precisely, I will be very, very unhappy :)

We prefer to spread our projects on several databases (the separation is based on domain scopes) and schemas (there are no strong rules, but we prefer to create separate schemas for each API segment).

Good luck, guys! Be happy:)</description>
		<content:encoded><![CDATA[<p>&gt; If you have big subset of table group than it makes sense to give prefix for this table group. Prefix should be separated by _. </p>
<p>&gt; Use following naming convention for Stored Procedure. sp_[_] Where action is: Get, Delete, Update, Write, Archive, Insert… i.e. verb </p>
<p>Use SCHEMAs, Luke :)</p>
<p>I&#8217;d like to see good old approach &#8220;fit all that info in that damn short name&#8221;. But I&#8217;ll not be happy if I find it in our projects. Precisely, I will be very, very unhappy :)</p>
<p>We prefer to spread our projects on several databases (the separation is based on domain scopes) and schemas (there are no strong rules, but we prefer to create separate schemas for each API segment).</p>
<p>Good luck, guys! Be happy:)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: SQL SERVER - Guidelines and Coding Standards Complete List Download Journey to SQL Authority with Pinal Dave</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-43240</link>
		<dc:creator>SQL SERVER - Guidelines and Coding Standards Complete List Download Journey to SQL Authority with Pinal Dave</dc:creator>
		<pubDate>Thu, 25 Sep 2008 10:34:31 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-43240</guid>
		<description>[...] SQL SERVER - Guidelines and Coding Standards Part - 1 [...]</description>
		<content:encoded><![CDATA[<p>[...] SQL SERVER &#8211; Guidelines and Coding Standards Part &#8211; 1 [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Kamran Shahid</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-43199</link>
		<dc:creator>Kamran Shahid</dc:creator>
		<pubDate>Wed, 24 Sep 2008 07:39:16 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-43199</guid>
		<description>Another nice post.

What About composite Primary Key

[
    *  Primary Key : PK_

      Example:

      PK_UserDetails

      PK_ Emails
]
??</description>
		<content:encoded><![CDATA[<p>Another nice post.</p>
<p>What About composite Primary Key</p>
<p>[<br />
    *  Primary Key : PK_</p>
<p>      Example:</p>
<p>      PK_UserDetails</p>
<p>      PK_ Emails<br />
]<br />
??</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Gadi</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-43176</link>
		<dc:creator>Gadi</dc:creator>
		<pubDate>Tue, 23 Sep 2008 19:11:52 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-43176</guid>
		<description>I find that when coding SQL queries with multiple joins that this format is more readable.

SELECT Username, Password
FROM UserDetails ud INNER JOIN 
          Employee e ON e.EmpID = ud.UserID

This was I can easily see which tables are included in the query.</description>
		<content:encoded><![CDATA[<p>I find that when coding SQL queries with multiple joins that this format is more readable.</p>
<p>SELECT Username, Password<br />
FROM UserDetails ud INNER JOIN<br />
          Employee e ON e.EmpID = ud.UserID</p>
<p>This was I can easily see which tables are included in the query.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-43169</link>
		<dc:creator>pinaldave</dc:creator>
		<pubDate>Tue, 23 Sep 2008 16:02:37 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-43169</guid>
		<description>Speednet,

Your suggestions are valuable.

Kind Regards,
Pinal</description>
		<content:encoded><![CDATA[<p>Speednet,</p>
<p>Your suggestions are valuable.</p>
<p>Kind Regards,<br />
Pinal</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Speednet</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-43168</link>
		<dc:creator>Speednet</dc:creator>
		<pubDate>Tue, 23 Sep 2008 15:57:51 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-43168</guid>
		<description>I&#039;m such a dope, I called you by your last name, sorry Pinal.</description>
		<content:encoded><![CDATA[<p>I&#8217;m such a dope, I called you by your last name, sorry Pinal.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: pinaldave</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-43165</link>
		<dc:creator>pinaldave</dc:creator>
		<pubDate>Tue, 23 Sep 2008 15:00:46 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-43165</guid>
		<description>Speednet,

I appreciate your feedback. I will follow up on it.

Kind Regards,
Pinal</description>
		<content:encoded><![CDATA[<p>Speednet,</p>
<p>I appreciate your feedback. I will follow up on it.</p>
<p>Kind Regards,<br />
Pinal</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Speednet</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-43163</link>
		<dc:creator>Speednet</dc:creator>
		<pubDate>Tue, 23 Sep 2008 14:18:30 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-43163</guid>
		<description>No dice, I&#039;m not sure how to indent in the comments section.  Sorry for the multiple comments.  

There is one intent on everything between the WHILE and the final END; and there are two indents on the INSERT.</description>
		<content:encoded><![CDATA[<p>No dice, I&#8217;m not sure how to indent in the comments section.  Sorry for the multiple comments.  </p>
<p>There is one intent on everything between the WHILE and the final END; and there are two indents on the INSERT.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Speednet</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-43162</link>
		<dc:creator>Speednet</dc:creator>
		<pubDate>Tue, 23 Sep 2008 14:17:11 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-43162</guid>
		<description>My code indentation (tabs) did not make it through the parser.  Let&#039;s see if it will work with spaces.
--------
WHILE (@@FETCH_STATUS = 0) BEGIN

    IF (NOT EXISTS (SELECT 1 FROM [Subscription] (NOLOCK) WHERE ([CustomerID]=@CustomerID))) BEGIN
        INSERT [Subscription] ([Guid], [CustomerID]) VALUES (@GUID, @CustomerID);
    END;

    FETCH NEXT FROM [MyCursor] INTO @CustomerID;
END;
--------</description>
		<content:encoded><![CDATA[<p>My code indentation (tabs) did not make it through the parser.  Let&#8217;s see if it will work with spaces.<br />
&#8212;&#8212;&#8211;<br />
WHILE (@@FETCH_STATUS = 0) BEGIN</p>
<p>    IF (NOT EXISTS (SELECT 1 FROM [Subscription] (NOLOCK) WHERE ([CustomerID]=@CustomerID))) BEGIN<br />
        INSERT [Subscription] ([Guid], [CustomerID]) VALUES (@GUID, @CustomerID);<br />
    END;</p>
<p>    FETCH NEXT FROM [MyCursor] INTO @CustomerID;<br />
END;<br />
&#8212;&#8212;&#8211;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Speednet</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-43161</link>
		<dc:creator>Speednet</dc:creator>
		<pubDate>Tue, 23 Sep 2008 14:13:31 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-43161</guid>
		<description>Hi Dave,

Very nice blog post.  Standards in SQL are on area that people do not think about enough, so I&#039;m very happy to see this.  I&#039;m also happy to see that many things I personally have as standards match up well to yours.

A little feedback on a few items you mentioned:

I have always used the table name to describe what is being stored in each individual row, rather than using the name to describe the container itself.  That specifically eliminates the addition of an &quot;s&quot; at the end (in most cases).  So I refer to the &quot;customer&quot; table, not the &quot;customers&quot; table.

For SP naming conventions, I like making the names a bit shorter and in a different order.  The main goal for me is that the SPs are easy to group and find in SQL Server Management Studio.  I actually use camelCase:



For example, if I&#039;m writing a SP for the Google Web site, a SP name might be &quot;googleEmailUpdate&quot;.

By placing the Object/Table Name before the Acton, it is much easier to group and find the SPs in Management Studio.  It does not flow off the tongue quite as nicely, but finding SPs is a breeze.

I normally use a &quot;db&quot; prefix for system maintenance SPs, and I use a &quot;clr&quot; prefix for (you guessed it) CLR code.

(@Atif: in Management Studio, the system SPs are separated from the user&#039;s SPs -- they are in a different folder -- and they also use the &quot;[sys].&quot; prefix, so there shouldn&#039;t be any conflict with naming, even if you stick with &quot;sp&quot;.)

Something you didn&#039;t mention as a standard is the use of semi-colons.  My personal standard is to use a semi-colon everywhere they are optional.  Once you get into the habit, it is second-nature and not a bother at all.  On the contrary, it provides more robust code, because if you don&#039;t use semi-colons, you&#039;re relying on the parser to determine the end of your statement.

One other area I would like to comment on is your last point, about using BEGIN ... END only in cases where they surround multiple statements.  I humbly disagree.

I have struggled with how to write BEGIN ... END over the years, because they are visually clumsy.  But I finally came up with a method that has proved to be helpful and visually helpful.

I *always* use BEGIN ... END now, and I use them exactly like I use &quot;{&quot; and &quot;}&quot; brackets in C++/C# code. (K&amp;R style)

I place the BEGIN on the same line as the conditional/loop/block, I indent all the contained code, and I align the &quot;END;&quot; (don&#039;t forget semi-colons) with the block start.

For example (please ignore the code itself, which would be better served with a CTE):

WHILE (@@FETCH_STATUS = 0) BEGIN

	IF (NOT EXISTS (SELECT 1 FROM [Subscription] (NOLOCK) WHERE ([CustomerID]=@CustomerID))) BEGIN
		INSERT [Subscription] ([Guid], [CustomerID]) VALUES (@GUID, @CustomerID);
	END;

	FETCH NEXT FROM [MyCursor] INTO @CustomerID;
END;

You&#039;ll also notice that another standard of mine is to place one blank line before and after any BEGIN ... END block.  That greatly enhances readability.

I&#039;d suggest taking a complex SP you&#039;ve written, and re-write it using my suggestions about BEGIN ... END.  Then compare the readability to the old version.

Thanks again for putting together this fantastic blog entry Dave!

-Todd (&quot;Speednet&quot;)</description>
		<content:encoded><![CDATA[<p>Hi Dave,</p>
<p>Very nice blog post.  Standards in SQL are on area that people do not think about enough, so I&#8217;m very happy to see this.  I&#8217;m also happy to see that many things I personally have as standards match up well to yours.</p>
<p>A little feedback on a few items you mentioned:</p>
<p>I have always used the table name to describe what is being stored in each individual row, rather than using the name to describe the container itself.  That specifically eliminates the addition of an &#8220;s&#8221; at the end (in most cases).  So I refer to the &#8220;customer&#8221; table, not the &#8220;customers&#8221; table.</p>
<p>For SP naming conventions, I like making the names a bit shorter and in a different order.  The main goal for me is that the SPs are easy to group and find in SQL Server Management Studio.  I actually use camelCase:</p>
<p>For example, if I&#8217;m writing a SP for the Google Web site, a SP name might be &#8220;googleEmailUpdate&#8221;.</p>
<p>By placing the Object/Table Name before the Acton, it is much easier to group and find the SPs in Management Studio.  It does not flow off the tongue quite as nicely, but finding SPs is a breeze.</p>
<p>I normally use a &#8220;db&#8221; prefix for system maintenance SPs, and I use a &#8220;clr&#8221; prefix for (you guessed it) CLR code.</p>
<p>(@Atif: in Management Studio, the system SPs are separated from the user&#8217;s SPs &#8212; they are in a different folder &#8212; and they also use the &#8220;[sys].&#8221; prefix, so there shouldn&#8217;t be any conflict with naming, even if you stick with &#8220;sp&#8221;.)</p>
<p>Something you didn&#8217;t mention as a standard is the use of semi-colons.  My personal standard is to use a semi-colon everywhere they are optional.  Once you get into the habit, it is second-nature and not a bother at all.  On the contrary, it provides more robust code, because if you don&#8217;t use semi-colons, you&#8217;re relying on the parser to determine the end of your statement.</p>
<p>One other area I would like to comment on is your last point, about using BEGIN &#8230; END only in cases where they surround multiple statements.  I humbly disagree.</p>
<p>I have struggled with how to write BEGIN &#8230; END over the years, because they are visually clumsy.  But I finally came up with a method that has proved to be helpful and visually helpful.</p>
<p>I *always* use BEGIN &#8230; END now, and I use them exactly like I use &#8220;{&#8221; and &#8220;}&#8221; brackets in C++/C# code. (K&amp;R style)</p>
<p>I place the BEGIN on the same line as the conditional/loop/block, I indent all the contained code, and I align the &#8220;END;&#8221; (don&#8217;t forget semi-colons) with the block start.</p>
<p>For example (please ignore the code itself, which would be better served with a CTE):</p>
<p>WHILE (@@FETCH_STATUS = 0) BEGIN</p>
<p>	IF (NOT EXISTS (SELECT 1 FROM [Subscription] (NOLOCK) WHERE ([CustomerID]=@CustomerID))) BEGIN<br />
		INSERT [Subscription] ([Guid], [CustomerID]) VALUES (@GUID, @CustomerID);<br />
	END;</p>
<p>	FETCH NEXT FROM [MyCursor] INTO @CustomerID;<br />
END;</p>
<p>You&#8217;ll also notice that another standard of mine is to place one blank line before and after any BEGIN &#8230; END block.  That greatly enhances readability.</p>
<p>I&#8217;d suggest taking a complex SP you&#8217;ve written, and re-write it using my suggestions about BEGIN &#8230; END.  Then compare the readability to the old version.</p>
<p>Thanks again for putting together this fantastic blog entry Dave!</p>
<p>-Todd (&#8220;Speednet&#8221;)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Atif Shehzad</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-43143</link>
		<dc:creator>Atif Shehzad</dc:creator>
		<pubDate>Tue, 23 Sep 2008 06:54:36 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-43143</guid>
		<description>To differentiate from system stored procedures, should not we use &quot;usp&quot; instead of &quot;sp&quot; prefix.

Regards</description>
		<content:encoded><![CDATA[<p>To differentiate from system stored procedures, should not we use &#8220;usp&#8221; instead of &#8220;sp&#8221; prefix.</p>
<p>Regards</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Chella Ganesh</title>
		<link>http://blog.sqlauthority.com/2008/09/23/sql-server-coding-standards-guidelines-part-1/#comment-43141</link>
		<dc:creator>Chella Ganesh</dc:creator>
		<pubDate>Tue, 23 Sep 2008 04:54:07 +0000</pubDate>
		<guid isPermaLink="false">http://sqlauthority.wordpress.com/?p=1107#comment-43141</guid>
		<description>Simply great!!!. I am a regular reader of this blog. Thanks for having excellent compilations like this.

Regards
Chella Ganesh</description>
		<content:encoded><![CDATA[<p>Simply great!!!. I am a regular reader of this blog. Thanks for having excellent compilations like this.</p>
<p>Regards<br />
Chella Ganesh</p>
]]></content:encoded>
	</item>
</channel>
</rss>
