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

Writing Before Reading

This editorial was originally published on May 21, 2020. It is being republished as Steve is gone this week. Have your thoughts changed on reading and writing code?

Coding is one of the few (or maybe only) places where we learn to write a language before we learn to read it. Many of us get started in some way by working through exercises, looking at very small snippets of code and then starting to write our own. Perhaps that's because we experiment by changing the behavior of the computer, which naturally takes some writing work on our part.

Perhaps we can do better, and should to better. Perhaps we would become less susceptible to the Not Invented Here (NIH) stance that so many developers seem to take. Not with major projects, but often with small sections of code or libraries, preferring to structure something new than re-used (and take the time to understand) what's already there.

This isn't to imply that most developers need to write their own code or don't work to understand others, but often they prefer to rebuild something in a way that is more familiar. It's a form of the Mere-exposure effect, and it sometimes leads developers to prefer certain patterns, tools, platforms, and more. Perhaps it's the opposite of the shiny ball syndrome, which leads people to chase the newest thing available in their area.

I know there are plenty of developers that copy and paste code from the Internet as well, which might seem to be a way of getting around NIH syndrome, but I think many people do this when they find code that solves a problem. Even if they don't understand how it works, they'll seek to reapply that same code to a new problem.

I do think reading code is hard. In some sense, it sucks. I'd often prefer to understand the basic inputs and outputs, perhaps rewriting the code to work in a way that's more comfortable for me to understand. Maybe I better understand my own code, maybe I'm falling victim to the IKEA effect (I'd rather depend on my own software than someone else's), or maybe I'm just being lazy.

There are plenty of articles on how to read other people's code, and I am trying to get better at this. I do try to debug and reason out how queries are written that solve problems in the forums. I may break apart queries and try to understand how someone has used a window function or a CROSS APPLY in a certain way. It helps build my skills, but it also helps me learn to better read other people's code and perhaps carry that skill into the future.

Steve Jones - SSC Editor

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

 
 Featured Contents
Stairway TDE

Restoring Azure Key Vault Keys and Validating SQL Server TDE Recovery: Level 7 of the Stairway to TDE

VishnuGupthanSQLPowershellDBA from SQLServerCentral

Learn about restoring your keys from an Azure Key Vault in the event of a DR situation.

External Article

There Are Days When I Feel Like Giving Up on the Plan Cache and Query Store.

Additional Articles from Brent Ozar Blog

In theory, SQL Server performance monitoring is pretty simple: 1. Review the server’s top wait types, 2. Find the queries causing those wait types, 3. Fix those queries, or improve the way the server reacts to them (indexes, settings, etc.). But in practice, step 2 is awful because:

Blog Post

From the SQL Server Central Blogs - Programmatically Retrieving MLV Lineage and Refresh Times

Meagan Longoria from Data Savvy

Materialized lake views (MLVs) in Microsoft Fabric are an effective way to implement medallion architecture declaratively, but once you have a pipeline of MLVs in production, you need visibility...

Blog Post

From the SQL Server Central Blogs - The Notification Trap: How Input Fatigue Is Killing Deep Work in Tech

gbargsley from GarryBargsley

If you’ve been here before, you know this blog is usually about SQL Server, PowerShell, and the day-to-day work of being a DBA. Execution plans, availability groups, dbatools scripts...

SQL Server 2025 Unveiled: The AI-Ready Enterprise Database with Microsoft Fabric Integration

SQL Server 2025 Unveiled: The AI-Ready Enterprise Database with Microsoft Fabric Integration

Site Owners from SQLServerCentral

With built-in AI for application development and advanced analytics powered by Microsoft Fabric, SQL Server 2025 empowers you to innovate—securely and confidently. This book shows you how.

 

 Question of the Day

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

 

Creating a JSON Document IV

I have this data in a table called dbo.NFLTeams
TeamID  TeamName       City             YearEstablished
------  --------       ----             ---------------
1       Cowboys        Dallas           1960
2       Eagles         Philadelphia     1933
3       Packers        Green Bay        1919
4       Chiefs         Kansas City      1960
5       49ers          San Francisco    1946
6       Broncos        Denver           1960
7       Seahawks       Seattle          1976
8       Patriots       New England      1960
If I run this code, how many rows are returned?
SELECT 
  YearEstablished,
  json_objectagg(city : TeamName)
FROM dbo.NFLTeams
GROUP BY  YearEstablished;

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 Distance Metric

In the new VECTOR_DISTANCE() function in SQL Server 2025, the first parameter is the distance_metric. What is this?

Answer: This is the name of the distance metric algorithm used

Explanation: This is the name of the distance metric calculation to use. There are three to choose from. Ref: VECTOR_DISTANCE() - https://learn.microsoft.com/en-us/sql/t-sql/functions/vector-distance-transact-sql?view=sql-server-ver17

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.


Development - SQL Server 2014
BCA KCP Pondok Bambu Telpn/wa (08218171891) - Telpn/wa (08218171891) Pondok Bambu Center, Jl. Pahlawan Revolusi No.30 Blok A/5-6, RT.2/RW.2, Wil, Kec. Duren Sawit, Kota Jakarta Timur, Daerah Khusus Ibukota Jakarta 13430
BCA KCU RAWAMANGUN Telpn/wa (08218171891) - Jl. Paus No.81, RT.1/RW.8, Wil, Kec. Pulo Gadung, Kota Jakarta Timur, Daerah Khusus Ibukota Jakarta 13220
BCA KCP Utan Kayu Telpn/wa (08218171891) - Jl. Utan Kayu Raya No.94, RT.12/RW.10, Utan Kayu Utara, Kec. Matraman, Kota Jakarta Timur, Daerah Khusus Ibukota Jakarta 13120
Article Discussions by Author
SSC Spam - Comments posted to this topic are about the item SSC Spam
SQL Server 2022 - Development
BCA KCP Klender Telpn/wa (08218171891) - Jl. I Gusti Ngurah Rai No.8 A-B, RT.8/RW.6, Wil, Kec. Duren Sawit, Kota Jakarta Timur, Daerah Khusus Ibukota Jakarta 13470
BCA KCP Kramat Jati Telpn/wa (08218171891) - Jl. Raya Bogor No.19, RT.1/RW.4, Wil, Kec. Kramat jati, Kota Jakarta Timur, Daerah Khusus Ibukota Jakarta 13510
BCA KCP Pulogadung Telpn/wa (08218171891) - Telpn/wa (08218171891) Jl. Raya Bekasi No.B-C Km.19 No.30, RT.1/RW.6, Wil, Kec. Pulo Gadung, Kota Jakarta Timur, Daerah Khusus Ibukota Jakarta 13220
BCA KCP Kas Pegambiran Telpn/wa (08218171891) - Telpn/wa (08218171891) Jl. Pegambiran No.2B, RT.12/RW.7, Jati, Kec. Pulo Gadung, Kota Jakarta Timur, Daerah Khusus Ibukota Jakarta 13220
BCA KCP Buaran Raya Telpn/wa (08218171891) - Jl. Buaran Raya Blok A No. 100, RT.6/RW.dan 101, Wil, Kec. Duren Sawit, Kota Jakarta Timur, Daerah Khusus Ibukota Jakarta 13470
BCA KCP Abdul Muis Telpon. 083135766741 - WhatsApp 083135766741 Gedung Graha Motor City, Jl. Abdul Muis No.24-26 Level I Suite 101, Petojo Sel., Kecamatan Gambir, Kota Jakarta Pusat, Daerah Khusus Ibukota Jakarta 10160
BCA KCP Siantan Telp:Cs.083831618816 - WhatsApp:083831618816 Jl. Khatulistiwa No.16, Siantan Hilir, Kec. Pontianak Utara, Kota Pontianak, Kalimantan Barat 78242
BCA KCP Nusukan Telpon/wa:0821°8168°291 - BCA KCP Nusukan Telpon/wa:0821°8168°291.Jl. Kapten Piere Tendean No.79, Nusukan, Kec. Banjarsari, Kota Surakarta, Jawa Tengah 57135
BCA KCU BLOK A CIPETE Tlpn.0821•3111•185 - BCA KCU BLOK A CIPETE Tlpn.0821•3111•185 Jl. RS. Fatmawati Raya No.6 A, RT.1/RW.5, Cipete Sel., Kec. Cilandak, Kota Jakarta Selatan, Daerah Khusus Ibukota Jakarta 12410
BCA KCP Sawah Besar Telpon. 083135766741 - WhatsApp 083135766741 Jl. Sukarjo Wiryopranoto No.28 C, Kb. Klp., Kecamatan Gambir, Kota Jakarta Pusat, Daerah Khusus Ibukota Jakarta 10120
BCA KCP Pare No.Telpon:083135765355 - Whatsapp:083135765355 Jl. Pb. Sudirman Jl. Raya Kediri - Pare No.2, Plongko, Pare, Kec. Pare, Kabupaten Kediri, Jawa Timur 64211
 

 

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

 

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