Problems displaying this newsletter? View online.
SQL Server Central
Featured Contents
Question of the Day
Featured Script
Ad for State of Database Landscape survey
The Voice of the DBA
 

Practice Until You Don't Get It Wrong

I wrote recently about a bad first day for an intern. He/she was fired, without cause in my opinion, when a production database was damaged while following a document for developer setup. The situation felt like a mistake, and one that wasn't necessarily the fault of the individual. To me, this was extremely poor handling of the situation from a CTO.

In the discussion for the piece, someone pointed out that it might not just be a new employee who makes a mistake that causes downtime. Certainly, an inexperienced employee could have caused the issue, but I know there are plenty people with lots of time in a position who make similar mistakes. It could be that one who has been there a long time followed a poorly documented procedure for the first time, or applied the procedure to the wrong situation. Often, I find these are relatively simple mistakes because someone isn't as familiar with a protocol or skill as another person assumed they were.

In sports and the performance arts, I've heard a saying that says: amateurs practice until they get it right, but professionals practice until they don't get it wrong. It's the difference between just gaining a skill that you complete and continuing your learning to ensure that the execution of that skill is ingrained into your being. You internally build the muscle memory and skill to complete a task correctly over and over with practice.

In the database world, this might be the difference between someone that has restored a database (the amateur) and someone that regularly practices restores of not only full database backups, but differentials and logs, tail log backups, filegroup restores, and more (the professional). The former has a skill, but the latter is confident and likely to complete the skill in a variety of situations without error.

Practice won't prevent mistakes, especially under pressure, but lots of practice does help us learn how to perform better. We learn what options are available, what issues might arise, and which choices we should be making. Just as professional athletes and musicians can make mistakes, we can as well. However, those mistakes should be rare. We should get most things right as the product of numerous hours of working deeply in, and understanding, our craft.

Steve Jones - SSC Editor

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

Ad for State of Database Landscape survey
 
 Featured Contents
SQLServerCentral Article

Create an HTML Report on the Status of SQL Server Agent Jobs

Nisarg Upadhyay from SQLServerCentral

Learn how to query your jobs to produce a report that is formatted to make consuming the data easy for DBAs.

External Article

Which Should You Use: VARCHAR or NVARCHAR?

Additional Articles from Brent Ozar Blog

You’re building a new table or adding a column, and you wanna know which datatype to use: VARCHAR or NVARCHAR?

Blog Post

From the SQL Server Central Blogs - Scooby Dooing Episode 9: The Case of the Artificially Intelligent Villain

SQLEspresso from SQLEspresso

Welcome back, my fellow sleuths, to my mystery-inspired blog series! I’m having a ton of fun writing these, and I hope you’re enjoying the ride through SQL Server’s haunted...

Blog Post

From the SQL Server Central Blogs - SQL Server Alerts

Kevin3NF from Dallas DBAs

Don’t Let Trouble Sneak Up on You   Most SQL Servers run quietly. Until they don’t. By the time someone notices an application outage or a failed backup, you’re...

Learn Microsoft Fabric: A practical guide to performing data analytics in the era of artificial intelligence

Site Owners from SQLServerCentral

A step-by-step guide to harness the power of Microsoft Fabric in developing data analytics solutions for various use cases

 

 Question of the Day

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

 

The Last Good DBCC Run

I want to check when DBCC CHECKDB was last run on my Baseball database. What code should I use?

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)

SQL Server Ghosts

For Halloween, what are ghost records?

Answer: Records that are deleted from an index page, but aren't removed from the physical page

Explanation: Ghost records are those that are deleted, but not removed from pages. Happy Halloween! Ref: Ghost cleanup process guide - https://learn.microsoft.com/en-us/sql/relational-databases/ghost-record-cleanup-process-guide?view=sql-server-ver17

Discuss this question and answer on the forums

 

Featured Script

Powershell script to generate SQL server Inventory in CSV format

Srinivas Merugu from SQLServerCentral

This script is used to generate the output file as CSV format for list of server.

$isodate=Get-Date -format s
$isodate=$isodate -replace(":","")
$basepath="C:Report"
$instancepath=$basepath + "SQL Inventoryinstances.txt"
$outputfile="SQL InventoryOutPut1SQLServer_Inventory_" + $isodate + ".csv"
-- $((Get-Date).ToString('dd-MMM-yy'))
$outputfilefull = $basepath + $outputfile

$filePath = ""
$dt = new-object "System.Data.DataTable"
foreach ($instance in get-content $instancepath)
{
$instance
$cn = new-object System.Data.SqlClient.SqlConnection "server=$instance;database=msdb;Integrated Security=sspi"
$cn.Open()
$sql = $cn.CreateCommand()
$sql.CommandText = "
create table #SVer(ID int, Name sysname, Internal_Value int, Value nvarchar(512))
insert #SVer exec master.dbo.xp_msver

declare @SmoRoot nvarchar(512)
DECLARE @sn NVARCHAR(128)
DECLARE @sa NVARCHAR(128)
exec master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE', N'SOFTWAREMicrosoftMSSQLServerSetup', N'SQLPath', @SmoRoot OUTPUT
EXEC master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE',N'SYSTEMCurrentControlSetservicesSQLSERVERAGENT',N'ObjectName', @sn OUTPUT;
EXEC master.dbo.xp_instance_regread N'HKEY_LOCAL_MACHINE',N'SYSTEMCurrentControlSetservicesMSSQLSERVER',N'ObjectName', @sa OUTPUT;

SELECT
@@SERVERNAME as ServerName,@@ServiceName as [InstanceName],

case when convert(varchar(100), SERVERPROPERTY(N'ProductVersion')) like '12.%' then 'SQL Server 2014'
when convert(varchar(100), SERVERPROPERTY(N'ProductVersion')) like '11.%' then 'SQL Server 2012'
when convert(varchar(100),SERVERPROPERTY(N'ProductVersion')) like '10.5%' then 'SQL Server 2008R2'
when convert(varchar(100),SERVERPROPERTY(N'ProductVersion')) like '10.0%' then 'SQL Server 2008'
when convert(varchar(100),SERVERPROPERTY(N'ProductVersion')) like '10.0%' then 'SQL Server 2008'
when convert(varchar(100),SERVERPROPERTY(N'ProductVersion')) like '9.0%' then 'SQL Server 2005'
else 'Not Found'
end as VersionName,
SERVERPROPERTY(N'ProductVersion') AS [Number],
SERVERPROPERTY('ProductLevel') AS SP,
CAST(SERVERPROPERTY(N'Edition') AS sysname) AS [Edition],
case when CAST(SERVERPROPERTY('IsClustered') AS bit) =1 then 'YES'
else 'NO' END
AS [IsClustered],
case when CAST(SERVERPROPERTY('IsClustered') AS bit)= 1 then (select serverproperty('ComputerNamePhysicalNetBIOS'))
else NULL END as Active_Node_Name,
(SELECT NodeName
FROM sys.dm_os_cluster_nodes where NodeName !=(select serverproperty('ComputerNamePhysicalNetBIOS'))) as Passive_Node_Name,
CASE
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('ISHADREnabled')) like 0 THEN 'Disabled'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('ISHADREnabled')) like 1 THEN 'Enabled'
ELSE 'unknown'
END AS ISHADREnabled,
CASE
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('HadrManagerStatus')) like 0 THEN 'Not started'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('HadrManagerStatus')) like 1 THEN 'Started'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('HadrManagerStatus')) like 2 THEN 'Not started'
ELSE 'unknown'
END AS HadrManagerStatus,
CASE SERVERPROPERTY('IsIntegratedSecurityOnly')
WHEN 1 THEN 'Windows Authentication'
WHEN 0 THEN 'Windows and SQL Server Authentication'
END as [Authentication Mode],
@sa as [SQLService_Account],
@sn as [SQLAgent_Account],
(SELECT value_in_use FROM sys.configurations WHERE name like '%max server memory%')AS max_server_memory_MB,
(SELECT value_in_use FROM sys.configurations WHERE name like '%min server memory%')AS min_server_memory_MB,
convert(sysname, serverproperty(N'collation')) AS [Collation],
(select Value from #SVer where Name = N'ProductName') AS [Product],
--(select Value from #SVer where Name = N'Language') AS [Language],
(select Value from #SVer where Name = N'Platform') AS [Platform],

(select Internal_Value from #SVer where Name = N'ProcessorCount') AS [Processors],
(select Value from #SVer where Name = N'WindowsVersion') AS [OSVersion],
(select Internal_Value from #SVer where Name = N'PhysicalMemory') AS [PhysicalMemory_In_MB],
@SmoRoot AS [RootDirectory],
SERVERPROPERTY('InstanceDefaultDataPath') AS InstanceDefaultDataPath,
SERVERPROPERTY('InstanceDefaultLogPath') AS InstanceDefaultLogPath,
SERVERPROPERTY('FilestreamShareName') AS FilestreamShareName,

CASE
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('EngineEdition')) like 1 THEN 'Personal or Desktop Engine'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('EngineEdition')) like 2 THEN 'Standard'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('EngineEdition')) like 3 THEN 'Enterprise'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('EngineEdition')) like 4 THEN 'Express'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('EngineEdition')) like 5 THEN 'SQL Database'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('EngineEdition')) like 6 THEN 'SQL Data Warehouse'
WHEN CONVERT(VARCHAR(128), SERVERPROPERTY ('EngineEdition')) like 8 THEN 'Managed Instance'

ELSE 'unknown'
END AS EngineEdition,
SERVERPROPERTY('IsFullTextInstalled') AS IsFullTextInstalled,
SERVERPROPERTY('LicenseType') AS LicenseType

drop table #SVer
"
$rdr = $sql.ExecuteReader()
$dt.Load($rdr)

$cn.Close()
}

$dt | export-csv -NoTypeInformation $outputfilefull

$filepath=$outputfilefull

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 2016 - Administration
SQLPS and syspolicy_purge_history job - The SQLPS.exe file has gone AWOL on 2 of my 4 SQL servers, ie, not in the path select Agent_exe from msdb.dbo.syssubsystems where subsystem = 'PowerShell'​ nor anywhere to be found on these machines. As a result, syspolicy_purge_history fails. And in fact, the job's status is "suspended", and I can't even stop it. I am […]
SQL Server 2019 - Development
how to write this query? - Hi everyone I am a bit stuck on how to write this query. Below is test data: drop table if exists #price_cutoff drop table if exists #nr_data drop table if exists #nt_data create table #price_cutoff ( [SYMBOL] [nvarchar](10) NOT NULL, [TRADE_DATE] [date] NOT NULL, [NR_PRICE] [float] NULL, [NT_PRICE] [float] NULL ) create table #nr_data ( […]
Line number in error message doesn't match up with line number in code - Hi everyone I have a 1000 plus line query and I am getting an error: Msg 8115, Level 16, State 6, Procedure dbo.TestQuery, Line 1036 [Batch Start Line 2] Arithmetic overflow error converting float to data type numeric. It says line 1036 but when I go to that line I get something that can't possible […]
Analysis Services
Automatically generate tabular model partitions - Hi. I hope someone can give some useful suggestions. My workplace have a suite of SSAS tabular models. They used to be created in compatibility level 1103. We then used a free piece of software with them called Partition Manager (which was a free download from Codeplex, to show it's age!) to dynamically generate partitions […]
Anything that is NOT about SQL!
Are things getting beyond reason? - My wife apparently ask her phone a question and below is what she sent me in the answer to her query.  I look at this and can only shake my head in wonder.  If this is AI in action, I think it's time to kill it off.  Imagine the bandwidth required to move this much […]
Editorials
Be Wary of Data - Comments posted to this topic are about the item Be Wary of Data
I Love Editorials - Comments posted to this topic are about the item I Love Editorials
The Journey to PostgreSQL (or anything) - Comments posted to this topic are about the item The Journey to PostgreSQL (or anything)
Article Discussions by Author
Locking Hierarchies - Comments posted to this topic are about the item Locking Hierarchies
Why Indexes are Important Beyond Faster Execution of Queries - Comments posted to this topic are about the item Why Indexes are Important Beyond Faster Execution of Queries
Powershell script to generate SQL server Inventory in CSV format - Comments posted to this topic are about the item Powershell script to generate SQL server Inventory in CSV format
Database Ledger in SQL Server 2022 - Comments posted to this topic are about the item Database Ledger in SQL Server 2022
Azure SQL Database MAXDOP - Comments posted to this topic are about the item Azure SQL Database MAXDOP
Building a RESTful API with FastAPI and PostgreSQL - Comments posted to this topic are about the item Building a RESTful API with FastAPI and PostgreSQL
SQL Server 2022 - Development
repeat results without loops, MSSQL2005 Express - hello everybody, new here and this is my first question I have a table contains: Name, Id, joinDate My question is that: I need a query to list all years between current date and joinDate, as the following as instance: Id------------------------Name----------------------empDate 1--------------------------John-----------------------6-8-2020 result: 1--------------------------John-----------------------6-8-2021 1--------------------------John-----------------------6-8-2022 1--------------------------John-----------------------6-8-2023 1--------------------------John-----------------------6-8-2024 1--------------------------John-----------------------6-8-2025 Thanks in advance.
 

 

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

 

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