SQLServerCentral - www.sqlservercentral.com

A community of more than 1,600,000 database professionals and growing

Featured Contents

Featured Script

The Voice of the DBA

Better Comments

I assume most of your comment your code.

Well, you probably comment code most of the time.

I'd bet your comments have quite a bit of detail.

And you do this completely inconsistently.

That's what I'd think, or maybe just what I want. Even the best developers I know will not consistently comment code. You can drift through any project on Github and see this. Those projects on GitHub might even be better documented because people know they are public. In most corporate environments I have worked in, I'll find that when people get busy, or distracted, or even when they're experimenting to find a solution, and they don't write detailed comments. Usually only when someone fixes a bug, with a solution found quickly, do I get a really useful comment.

There are all sorts of ways that people think about commenting their code. I ran across a post from Annette Allen about adding comments. She noted that she has headers in her stored procedures and other comments. However, after a few months, she wasn't sure that the comments actually helped her. I've had that same feeling at times when looking back at comments, both mine and others.

Do you have a method for choosing the words you use to comment code? Jeff Atwood says to comment on why you did something, not what. I've seen that before, especially with version control commit comments. We often can look at code to determine what it does, and if you use a VCS extensively, then you can always see the changes that were made between versions. The comments typically give me some rationale for the work I did. Over time, I find that if I think about how I'd explain my reasoning to myself in the future, I come up with a good comment.

You might feel differently, and if so, please let me know. Perhaps there are some good ideas you have about choosing comments, and perhaps you have examples. Some might include a bug or Jira number, which I like, but others may hate. These could be comments inline in code or those you use when comimtting to a VCS.

Share some thoughts today, and if you have any entries for the best code comment, drop them here.

Steve Jones from SQLServerCentral.com

Join the debate, and respond to today's editorial on the forums


The Voice of the DBA Podcast

Listen to the MP3 Audio ( 3.1MB) podcast or subscribe to the feed at iTunes and Libsyn. feed

The Voice of the DBA podcast features music by Everyday Jones. No relation, but I stumbled on to them and really like the music.

ADVERTISEMENT
SQL In The City

SQL in the City Streamed – Compliant DevOps: June 20 2018

Join Redgate’s livestream on June 20 and learn from Microsoft Data Platform MVPs, Steve Jones, Grant Fritchey and Kathi Kellenberger. The schedule will include sessions to help you learn how to demonstrate compliance with regulations such as the GDPR, HIPAA and SOX. Find out more and register for free

SQL In The City

SQL in the City Streamed – Compliant DevOps: June 20 2018

Join Redgate’s livestream on June 20 and learn from Microsoft Data Platform MVPs, Steve Jones, Grant Fritchey and Kathi Kellenberger. The schedule will include sessions to help you learn how to demonstrate compliance with regulations such as the GDPR, HIPAA and SOX. Find out more and register for free

Featured Contents

 

I thought my database was collation agnostic

Thomas Romeo from SQLServerCentral.com

My struggles with a customer's database that used a different collation sequence. The easy way is never the right way, or is it? More »


 

How to Create Deadlocks and Troubleshoot Them

Additional Articles from Brent Ozar Unlimited Blog

Watch in awe and wonder as Brent Ozar creates a deadlock, then uses sp_BlitzLock after the fact to show you which queries and tables were involved. More »


 

From the SQLServerCentral Blogs - Interview questions: What’s the first thing you would do if a user reports slowness.

Kenneth Fisher from SQLServerCentral Blogs

We’ve been doing a fair amount of interviewing recently and one of our big questions is What do you do... More »


 

From the SQLServerCentral Blogs - What Does The GO Command Do?

Bert Wagner from SQLServerCentral Blogs

Watch this week’s episode on YouTube. When I started working with T-SQL, I thought the GO command was optional, kind of... More »

Question of the Day

Today's Question (by Steve Jones):

What are the options for automatic tuning in Azure SQL Database (May 2018)?

Think you know the answer? Click here, and find out if you are right.


We keep track of your score to give you bragging rights against your peers.
This question is worth 1 point in this category: Automatic tuning.

We'd love to give you credit for your own question and answer.
To submit a QOTD, simply log in to the Contribution Center.

ADVERTISEMENT

Design and configure SQL Server instances and databases in support of high-throughput applications that are mission-critical and provide consistent response times in the face of variations in user numbers and query volumes. Learn to configure SQL Server and design your databases to support a given instance and workload.

Pick up your copy of this great book today at Amazon today.

Yesterday's Question of the Day

Yesterday's Question (by Evgeny Garaev):

How can I use a Windows shared folder on a Linux server?

Answer: Mount the Windows share as a CIFS share

Explanation:

Mounting the Windows folder as a CIFS (Common Internet File System)  share is the right answer.

Ref: Mounting an SMB Share -  click here


» Discuss this question and answer on the forums

Featured Script

Database-based Transaction Counting Find Script

Yusuf Kahveci from SQLServerCentral.com

Within the last minute you can learn about our transaction volume on our database with our script below.

NOTE: You can monitor the number of transactions that occur within the range of 10 minutes, 2 minutes, etc., by entering the desired time interval into the WAITFOR DELAY statement.
This script can also be graphically monitored in charts via SSRS by being converted into Jobs in certain periods.
Yusuf KAHVECI
yusufkahveci@sqlturkiye.com
www.sqlturkiye.com
Thanks.

More »

Database Pros Who Need Your Help

Here's a few of the new posts today on the forums. To see more, visit the forums.

SQL Server 2017 : SQL Server 2017 - Development

Looking for best way to summarize some data - Hi all, Hope i'm posting this in the right place, if not, please let me know. I have a table like this: [code...


SQL Server 2016 : SQL Server 2016 - Administration

restore/Attach not working as expected - To All, I have done many restores or attaches of db's and yet this particular one is not working as it...

AlwaysOn Availability Groups Failover. - Hi, I'm in the process of setting up an AOAG cluster. This is my first time doing this, so I'm definitely...

Regulary delete and rebuild of table influences perfomance? - Ahoi, Situation: i have a table with around 40 million rows and a clustered primary key set by IDENTITY(1,1). Theres regulary deletes and...

SQL Server 2016 Standard Edition - help - I need to encrypt my database and I have the standard edition SP1. With the standard edition I cant use...


SQL Server 2016 : SQL Server 2016 - Development and T-SQL

DelimitedSplit8k and Performance - I am working on taking data out of an ERP system and into a data warehouse.  One of the unfortunate...

Can anyone explain why this isn't populating the two desired columns? - Hi, Please see the below query. When executing this query I find two derived columns and [Candidate Second...

Compare comma separated values - Hi,    let's say I have this: DROP TABLE IF EXISTS #CSV CREATE TABLE #CSV (ID INT NOT NULL, LIST VARCHAR(30) NOT NULL ) INSERT...

Wht is the best way to load 15 million rows into a table with a pk? There are known duplicates. - Good morning, I have a table that needed a Primary key on the table id column (tableID int).  The table has...


SQL Server 2014 : Development - SQL Server 2014

How to spread an invoice tax across invoice lines without loosing rounded remainder in a view? - I have a view, which shows Invoice Details table. This view is used to print invoices to the customers. In...

update table: PK or unique idx? - Hi, There's this table with 300000000 rows and about 40 columns  the pk consists of three fields massive updates are made on...

Die whitespace, DIE !! - Hi all,  Trying to delete some white spacebar as follows...      /****** Object:  Table .    Script Date: 04/06/2018 22:43:46 ******/ SET ANSI_NULLS ON GOSET...


SQL Server 2008 : SQL Server 2008 - General

How do you do select and update together that actually works? - Right now under company information profile when I click save button it goes through this code: Dim RS As Recordset  Dim...

Primary key incrementation - Hello, I know from Microsoft Access when you enter any value in any column it automatically adds a new row and...

xp_create_subdir for non-sysadmins - Hi, Is it possible for non-sysadmins to run xp_create_subdir on the Express version of 2008 R2? When researching the subject I...

Staging FIXML Data into SQL 2008 - Hi Guys, Anyone has experience with FIXML data? One of the vendors sent us a fixml file that we need to...


SQL Server 2008 : SQL Server Newbies

detect if previous record is higher or lower ? - In it's simplest form if I had a table that stored a persons name, date that the record was entered,...


SQL Server 2008 : SQL Server 2008 High Availability

Replication - Missing Data in Subscribers - I have a strange issue going on intermittently with one of our SQL servers. The setup we have is: 1. 1...


Data Warehousing : Integration Services

Mismatch or data overflow on MySQL Link Server - I try to Insert some records to my remote MySql from my SQL Server. The MySql is connected as Link server. The...


SQL Server 2005 : Administering

Installing sql 2005 using "disk1" and "disk 2" - Someone copied the contents of the sql 2005 cd's into folders caled "disk 1" and "disk 2" on a server. ...

This email has been sent to newsletter@newslettercollector.com. To be removed from this list, please click here.
If you have any problems leaving the list, please contact the webmaster@sqlservercentral.com.
This newsletter was sent to you because you signed up at SQLServerCentral.com.
Feel free to forward this to any colleagues that you think might be interested.
If you have received this email from a colleague, you can register to receive it here.
This transmission is ©2018 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.
Contact: webmaster@sqlservercentral.com