Problems displaying this newsletter? View online.
SQL Server Central
Featured Contents
Question of the Day
The Voice of the DBA
 

The Worst Comments

This editorial was originally published on Mar 13, 2015. It is being republished as Steve is on vacation.

I was watching a presentation recently on refactoring C# code and was amazed by some of the comments that the speakers showed in the code. The example was a real application that had been obfuscated and simplified a bit for the talk. The comments, however, had only been changed when they might disclose a specific person or company. The speakers pointed out a few of those changes, but also noted that most of the comments were verbatim from the original code.

Comments like "Dave changed this from the old way"  or "Bug 445: as per the operations group" were good examples of bad comments. These items don't really help a developer understand the code. The comments in application code should be there to add to the code itself, helping someone understand a reason for the code, not an obscure reference or an obvious statement ("this code adds two balances together).

With that in mind, I'm sure many of you have come across some comments in code that have evoked a wide range of emotions. I'm sure you've been frustrated, annoyed, or something else. Perhaps even from your own comments. With that in mind...

What are the worst comments you have found in code?

I hope you don't have examples in your current application, but perhaps you do. Perhaps you have even committed your own code recently without really taking the time to accurately describe the change. Maybe you want to go look in your VCS and see what you've entered lately.

Steve Jones - SSC Editor

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

 
Redgate SQL Prompt
 Featured Contents
Stairway to DAX and Power BI

Stairway to DAX and Power BI - Level 10: Function / Iterator Function Pairs: The DAX Product() and ProductX() Functions

Bill Pearson from SQLServerCentral.com

As a part of his “Function / Iterator Pairs” mini-series, Business Intelligence architect, Analysis Services Maestro, and author Bill Pearson introduces the DAX Product()and ProductX() functions, discussing the syntax, uses and operation of each. He then provides hands-on exposure to Product()and ProductX(), respectively, in returning the product of numbers in a column and in returning the product of an expression evaluated for each row in a table.

SQL Server Triggers Pros and Cons

Additional Articles from MSSQLTips.com

In this tip we look at some of the advantages and disadvantages of using triggers in SQL Server.

Free eBook: Fundamentals of SQL Server 2012 Replication

Press Release from Redgate

Fundamentals of SQL Server 2012 Replication provides a hands-on introduction to SQL Server replication. The book introduces you to the technologies that make up replication, and then walks you through setting up different replication scenarios. When you've finished reading, you should be able to implement your own multi-server replication setup while following the principle of least privilege.

From the SQL Server Central Blogs - Information Measurement with SQL Server Part 4.5: The Squared L2 Family of Distances

SQLServerSteve from SQLServerCentral

By Steve Bolton …………In the last two installments of this series of amateur self-tutorials (apart from the Fisher Information article, which I deliberately published out of order), I introduced...

From the SQL Server Central Blogs - Pathways to Progress

Diligentdba 46159 from SQLServerCentral

One of the most significant and hardest challenges we face as data professionals (or generally anyone in IT) is how to keep up with learning. Most of us are...

 

 Question of the Day

Today's question (by Steve Jones - SSC Editor):

 

Properly loading the data frame

I've got a CSV file that looks like this:
"ProcName","cputime","reads"
"GetCustomers","27784","312165"
"GetCustomerList","43170","627272"
"CalculateMonthlyTotals","48868","2705414"
"CalculateMonthlyTotals","25868","2922859"
I want to import this in RStudio, and run this:
procs <- read.csv2("C:\\Users\\Steve\\Documents\\SQL Server Management Studio\\procexecutions.csv", header=TRUE)
I then see this:
> head(procs)
                ProcName.cputime.reads
1            GetCustomers,27784,312165
2         GetCustomerList,43170,627272
3 CalculateMonthlyTotals,48868,2705414
4 CalculateMonthlyTotals,25868,2922859
5  CalculateMonthlyTotals,38206,862347
6           GetCustomers,49426,3449650
Why do I see all the data in one column?

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

 

 

 

 Yesterday's Question of the Day (by Steve Jones - SSC Editor)

Limiting Access

I have created a role for my junior DBAs with this code:

CREATE ROLE JuniorDBA
ALTER ROLE JuniorDBA ADD MEMBER SallyDev 
ALTER ROLE JuniorDBA ADD MEMBER JoeDBA
ALTER ROLE JuniorDBA ADD MEMBER SarahDBA
-- ...

I have granted a number of rights to this role:

GRANT SELECT ON dbo.UserAccessRoles TO JuniorDBA
GRANT SELECT ON dbo.ETLJobHistory TO JuniorDBA
GRANT SELECT ON dbo.DBALogger TO JuniorDBA
-- ...

If I run this, what happens?

REVOKE SELECT ON dbo.DatabaseSizeInfo FROM SallyDev

Answer: Nothing,

Explanation: If the permission is already granted, or the GRANT was never run before a DENY, nothing happens. There is no error. In this case, nothing changes because SallyDev was not granted access, so there is nothing to revoke. The role permissions are not altered. Ref: REVOKE - https://docs.microsoft.com/en-us/sql/t-sql/statements/revoke-transact-sql?view=sql-server-2017

Discuss this question and answer on the forums

 

 

 

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 - Administration
What is going on with my rebuilding index job? - We migrated a major server to a new cluster.  Installed SQL Server 2017 and set up all of the nodes and the AGs. After a couple of months, we started seeing an occasional blocking of jobs in the morning.  The indexoptimize_user_databases job was still running. We put in some code to kill the job at […]
Transaction Log (Waitype=Replication) - Hello all, I have an issue with my growing transaction log. When I query the log_reuse_wait_desc we found that it is pending for "replication". I have both transactional replication and CDC enabled at the same time. It means that it is actually sharing the same log reader agent. We are not sure which exactly the […]
SQL Server 2017 - Development
Dynamic query based of business rules - I hope you are well. I need your help and advice on a repetitive task that I would like to automate. Every month my manager asks me to run a series of SQL queries based on the same table and columns. I thought I could create a rules table that would allow him to create […]
TSQL query not working properly against Full Text Index - Hi, I've been having this issue for quite some time and need some help to understand it. I am not sure if this is an "expected behavior" or, as the user is indicating, an issue that needs to be fixed or corrected somehow from MSSQL. This query suppose to return two rows SELECT * FROM […]
SQL Server 2016 - Administration
memory leaks sql server 2016 Ent - Good day) I'm sorry for my English server 2016 Ent I have a problem with memory leaks SELECT sqlserver_start_time, physical_memory_kb/1024/1024 physical_memory_GB, committed_kb/1024/1024 committed_GB, committed_target_kb/1024/1024 committed_target_GB, visible_target_kb/1024/1024 visible_target_GB -- stack_size_in_bytes/1024/1024/1024 stack_size_GB FROM sys.dm_os_sys_info(nolock) physical_memory_GB =1023 committed_GB = 874 I try to freeproccache, buffercache, but this dont't help, only restart service help solve this problem for a […]
Row Level Security - Enabled but not Filtering - ...this is a 2nd attempt to post, as I can't seem to find the 1st from the day before...   I'm trying to implement row-level security in SQL Server 2016 but am getting stuck.  Below is the code being used for the predicate function, security policy and an intermediate table.  From what I can see, […]
SQL Server 2016 - Development and T-SQL
Insert query help - I have a table with the following data ( sample) Col1  Col2  Col3   Col 4 A     AA   ABC     ALL B    BA     BBC     A C   CA     CCC        ALL   I need the result as follows Col1  Col2  Col3   […]
Query help on Pivoting on two columns - DECLARE @RegionCounts Table ( TYear char(2), Region varchar(30), RowCnt int ) Insert into @RegionCounts values ('13','Latam',100) Insert into @RegionCounts values ('13','NOAM',200) Insert into @RegionCounts values ('14','Latam',300) Insert into @RegionCounts values ('14','NOAM',400) select * from @RegionCounts   I need the out put as [13latam] , [14latam], [13NOAM], [14NOAM] as column headers with corresponding values under it.
Administration - SQL Server 2014
Replication - Stop transactional replication steps, Step 1 Stop Log Reader Agent Local publication folder and then right click a publication Click View Snapshot Agent Status or View Log Reader Agent Status Click stop Step 2 Expand SQL Server Agent folder and then expland Jobs folder Click Stop REPL-Distribution Job Let me know if I am missing any? How long […]
Development - SQL Server 2014
Query containing while loop for dates taking increditbly long - Hi All, I'm hoping to get some insight to an issue we're experiencing with a query in an SSIS package, which has been taking ages to complete. It takes about 3 hours in our Dev environment, and progressively longer as we've tried deploying to the upper environments. We thought as first, it might have to […]
SQL Server 2008 - General
retrieve all .rdl files from report server - Is there a folder on the report server that houses all of the .rdl files for all of the reports. We need to add all of them to TFS. Was hoping we dont have to go through them one at a time.
T-SQL (SS2K8)
Help Needed in sql row to column - Hello, Below is my sample data with data as ( select 1 as ID,'Apple' as ProductName,'1' as serving, 'g' as unit union all select 1 as ID,'Orange' as ProductName,'2' as serving, 'mg' as unit union all select 1 as ID,'Pinapple' as ProductName,'1' as serving, 'g' as unit union all select 2 as ID,'Apple' as ProductName,'1' […]
Reporting Services
Issue with labels in a pie chart - I have the following issue with labels in the pie chart:   In the preview of Visual Studio the issue doesn't exist but if I save in pdf then I'll find the error inside the pdf. Please, there is someone can help me? It's urgent...
Continuous Integration, Deployment, and Delivery
Response to Bloor article on SQL Provision - I found the article https://www.sqlservercentral.com/articles/bloor-scores-sql-provision-4-5-out-of-5-for-test-data-provisioning Interesting if a little shallow.  It would be more convincing if it did some A-B comparisons with major competitors (e.g. Delphix, Actifio, Denodo and Rubrik and probably others).
Third Party Products
Idera SQL Compliance Manager, not showing events?? - Trying to test this out for work, to see if it might work for some of our monitoring requirements (security-type stuff, not performance) and I've got it up and running in a lab environment.  But.  The console isn't showing any events, despite me generating events it should be reporting (failed logins, etc) I've got it […]
 

 

RSS FeedTwitter

This email has been sent to {email}. 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.
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved.
webmaster@sqlservercentral.com

 

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -