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

What You Should Know About Coding

What are the important things you should know about writing T-SQL code in an organization, on a team? I'm sure that many of you have ideas, and please, feel free to share them with us. As you think about your answers, think about this as well: what do you with you'd have known when you started writing code?

I went through university quite some time ago, over 30 years ago, and some things have changed in this industry. Not so much in the way we structure code, though we have gotten much better in some ways. Rather the way that organizations work has dramatically changed. It's not just this new DevOps thing, but more that many organizations are starting to expect developers to do more than sit in a cube and react to a set of tickets or a specification written months ago.

More companies are expecting developers to think and interact with others, knowing more about other parts of their environemnt and application. More developers work in teams, and perhaps very interesting to me, the once dreaded and heavyweight code review that seemed to die during the middle of my career has become a commonplace, quick task that developers do every day now.

There's an interesting piece, written by Ryland Goldstein, about the things he thinks developers should be learning in college or early on. I thought it was interesting to see him open with lines of code as a metric, and show the growth in code for some large applications. To me, LoC hasn't been important at any point in my career, but I know it was talked about while I was in school.

He does talk about some things that good code should have, and I agree that most of the time the language doesn't matter. I do think his points on reading code, and learning to work with other people's code is good. To me, this really means we want to adapt and learn to write code in the style that our team uses. That can have a huge impact on group productivity, when we can write in a similar style, and then also read (and review) code quicker because it's all the same style.

Perhaps the best line is this: " Every single member of our team (including me) would have a full blown panic-attack if someone ever suggested committing un-reviewed code." I think too often the database side of things ends up committing (and deploying) un-reviewed code too often. We could to better, even if we need to teach someone how to review our code. Having a second set of inexperienced eyes might not prevent mistakes, but it certainly might help others learn to write better database code.

Steve Jones - SSC Editor

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

Redgate Database Devops
 
 Featured Contents

“Included columns” for non-clustered indexes explained

Michael Salzmann from SQLServerCentral

Microsoft SQL Server has the feature to use “Included columns” for the creation of non-clustered indexes. This feature and its benefits and disadvantages will be explained in the following article. Included columns can be used to create a covering indexes without including all the data into the key columns. This covering index has the advantage […]

Partitioning Data in SQL Server without using Partitioned Tables

Additional Articles from MSSQLTips.com

In this we look at how we to quickly split up data from a SQL Server table into relatively equal size buckets.

SQL Server 2019 Graph Database and SHORTEST_PATH

Steve Jones - SSC Editor from SQLServerCentral

With SQL Server 2019 on the way, it’s time to begin learning about all the new features. In this article, Dennes Torres demonstrates how to use the new SHORTEST_PATH function that is part of the Graph Database feature.

From the SQL Server Central Blogs - Use port forwarding to access SQL Server running in Kubernetes

dbafromthecold@gmail.com from The DBA Who Came In From The Cold

A really handy feature in Kubernetes is port forwarding. This can be used to narrow down an issue when connections are failing to SQL Server running in a cluster....

From the SQL Server Central Blogs - Using strace inside a SQL Server Container

aen from Anthony Nocentino's Blog

So, if you’ve been following my blog you know my love for internals. Well, I needed to find out exactly how something worked at the startup of a SQL...

 

 Question of the Day

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

 

Reindexing a database

The DBCC DBREINDEX command has been around for a long time in SQL Server. However, it has also been deprecated, meaning that future work should not use this and existing code that calls this should be refactored. What command should be used instead?

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)

The typo

I'm inserting some test data with an INSERT statement. I have a GO separator after this, but as I go to type CTRL+E to execute the query, I accidentally type a 5 in the editor and this gets executed.

 INSERT dbo.Claim
 (
     PharmNo,
     ClaimNo,
     ClaimDate
 )
 VALUES
 (
     'KLM', '123', GETDATE()
 )
 GO 5

What happens?

Answer: Five rows are inserted

Explanation: Adding a number after the GO separator in SSMS will cause the batch to run that number of times. In this case, the INSERT statement will be executed 5 times. Ref: GO - https://docs.microsoft.com/en-us/sql/t-sql/language-elements/sql-server-utilities-statements-go?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
Collation change - Hi, We recently built a server using a prebuilt AWS AMI and the default collation isn't what the application vendor asked for. We ran the sqlservr -m -T4022 -T3659 -s"SQL2017" -q"somecollation" command which seems to have changed the DB collations but the default server collation seems to still be the same SELECT CONVERT (varchar, SERVERPROPERTY('collation')) […]
SQL Server 2016 - Administration
Check if the statistics are off for table variables - Hi, How do I check if statistics are off for table variables? Thanks,
The EXECUTE permission was denied on the object for user in db_owner - Hello experts, A user who is in the db_owner role for a database reported that he is getting this error: Msg 229, Level 14, State 5, Procedure ReportProc, Line 1 [Batch Start Line 1] The EXECUTE permission was denied on the object... Does anyone know why EXECUTE would fail for an owner of the database? […]
Performance impact by running 2 scripts on the prod server. - I have 2 script which I want to run in our production environment since we don't have a monitoring tool in place and I have a feeling that there is a runaway query which is filling up the log file. The log file grows to be 300+ sometimes. We use DPM (Microsoft product) to take […]
SQL Server 2016 cannot show correct cpu cores in CPU affinity - Hi Guys, I wonder if SQL Server cannot support too many cpu cores? select @@version Microsoft SQL Server 2016 (SP2-CU8) (KB4505830) - 13.0.5426.0 (X64) Jul 21 2019 21:16:47 Copyright (c) Microsoft Corporation Enterprise Edition: Core-based Licensing (64-bit) on Windows Server 2016 Standard 10.0 (Build 14393: ) select * from sys.configurations where name = 'affinity […]
SQL Server 2016 - Development and T-SQL
wierd type conversion error - Hi I've been tracking through some code that has a type conversion error from varchar to uniqueidentifier I started commenting out parts of the code and found the offending line of code WHERE vaoq.Questionnaire_ID = '09C4C7B4-1275-460A-AE23-FFA9256B1ABE' I checked that this is a valid GUID (using convert) the only way I managed to get this fixed […]
Administration - SQL Server 2014
Table Rows deleted but not shrinking in size - Hi Folks, a general question here for better admin on a database. Have a number of tables, with approx 100 rows that clear down and re-populate every 5 minutes, however they're growing in size, up close to 10 gb even though the data is small. I deleted one of these tables, but the database is […]
SQL 2012 - General
Database Backup and corruption Jobs - Hi, Please advise of the below scenarios 1Q) I am trying to reduce the sql agent back up job running time. The job pickups a SSIS package which basically takes full backup of all user db's; which is taking 7+ hours to succeed  ( Due to the fact that 2 of the databases are of […]
SQL Server 2012 - T-SQL
SSIS - Why No Failure/Error On Truncation? - I tried Googling this but most complaints seem to be that SSIS is giving people truncation errors when they don't think they should have them. I'm having the opposite problem: my SSIS package is "successfully" loading a long string into a CHAR(6) column and SSIS/SQL Server (?) is automatically truncating it. It gives me a […]
SQL Server 2008 - General
Recycle SQL Agent Error Logs - hi all I want to keep 1 month worth of SQL agent Error logs and plan to cycle every week  by running : EXEC dbo.sp_cycle_agent_errorlog ( using SQL JOB) How do I do this ? Thanks All  
Reporting Services
permissions to connect to a report server 2016 - I have upgraded a vb.net web form application to be vb.net 2012. This application can currently call a report server that is 2008 or 2010 with no problem. I am trying to get this application to connect to a report server 2016. I am getting the error message, 'The permissions granted to user 'X\User' are […]
RC4 cipher disabled, Report Manager / Server no longer accessible - We not too long ago were required to remove / disable the RC4 cipher suite on our servers.  Shortly after that, I found I could no longer access the SSRS Report Manager and Report Server pages via IE.  At the time, this was not a pressing concern and I let it slide until just recently […]
SSRS 2014
trying to get everything to fit on 1 page - Hello, this might be very easy but not sure, i have an invoice, and after the invoice, i am trying to print the terms and conditions etc., however that needs to always be on a seperate own page... anyway to do that? example: invoice invoice info ... page 2 or page 3 depending on how […]
Powershell
Map a drive to a particular login and make it available all the time -   I am not sure if this is something possible, i would like to map a share to a drive letter using a particular login and if that login tries to hit that server remotely it should be able to see that mapped drive.
Analysis Services
MDX query: how to use the unequal operator between different attributes - Hi all, I am new to MDX and I have already tried Google to find a solution for my query but didn't get any answer by myself. For the use case, I have a role-play dimension (geography), a customer and store. Geography is used both in customer and store. I want to figure out, how […]
 

 

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

 

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