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

Daily Coping Tip

Be kind and supportive to everyone you interact with

I also have a thread at SQLServerCentral dealing with coping mechanisms and resources. Feel free to participate.

For many of you out there working in a new way, I'm including a thought of the day on how to cope in this challenging time from The Action for Happiness Coping Calendar. My items will be on my blog, feel free to share yours.

My Problem, or Yours?

Today we have a guest editorial as Steve is out of town. This editorial was originally published on 9 Aug 2017.

It's the nature of being in IT that things go wrong, often for less than obvious reasons. We start with the ritual question of "what changed?" and get the ritual answer of "nothing", and then we move on to figuring out the source of the problem (knowing that something did change!). The easy ones are easy, the hard ones test the culture because everyone is trying to quickly say "it's not my part of the stack".

You know how it goes. Application performance degrades and the devs yell DATABASE! It's unlikely (hmm) to be us, so we yell STORAGE and NETWORKING, because, well, those guys are always causing problems. Soon it's apparent that none of us caused the problem - it must be the code!

Not long ago I was working on a project to enhance security for a large company and part of that involved moving some servers to new subnets and tightening the firewall rules. We got all the teams (silos) together, planned the change carefully, and did the implementation. Things went smoothly and all the apps were working fine. Then overnight a database job took 6X the normal run time. The conversation about the slowness went about like this:

  • Database: Nothing changed on our side, job has been steady for months. It's not us.
  • Firewall: The app works, it's not us.
  • Network: The app works, it's not us.

My suggestion was that since the db had not changed, it seemed reasonable to think about how the changes to the firewall and network could be the cause. No give at all from those teams, they were certain it was not them. So, we rolled it all back, putting the db back in the old subnet. The next night, performance was back to normal. Faced with proof that the db really was working, the other teams went back and looked again. This time, looking harder, they found that packet inspection was enabled on the new subnet, but not the old one, and it was maxing out the CPU on the switch when the job ran. They turned that off, we moved everything back, and all was good.

More recently a server VM I use for remote admin began running really slow. Slow as in 15 minutes to boot. Windows guys blamed me, saying it had to be the tools I installed (seemed unlikely to me). Storage team says everything is normal. Same for the network. Weeks go by (weeks!) and the problem seems to come and go. Turning off AV seemed to help, which to me pointed to some kind of network/storage issue. Finally it happened on a different server and then everyone took a harder look. Turned out there was a bad cable on the switch and because the port was used in some kind of round robin fashion we only saw the problem at random times and it was worse when we did a lot of IO to network storage on that bad cable (like the AV scan and booting).

Sometimes it's them, sometimes it's us. I think because the nature of our work involves skewed data, plans falling out of cache, and fragmented indexes - the kinds of changes that don't cause a change management ticket to be created - that we look a little harder.

If we everyone says "not me" the only reasonable approach is for everyone to assume "it is me" and look again and keep looking until the cause is identified. It's interesting to think about why that's so often not the case, isn't it?

Andy Warren

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

 
 Featured Contents
Stairway to Columnstore Indexes

Stairway to Columnstore Indexes Level 3: Building The Columnstore

Hugo Kornelis from SQLServerCentral.com

The performance increase columnstore indexes grant when reading data from the index is offset by the expensive process required to build the index. In this Stairway level, Hugo Kornelis walks you through the steps SQL Server takes when building (or rebuilding) a columnstore index.

External Article

Database DevOps: Standardize, Automate, Monitor & Protect

Additional Articles from Redgate

See how our end-to-end framework for extending DevOps to your database enables your organization to balance the demand to deliver software fast with the need to protect and preserve business critical data.

Technical Article

Python Built-in Statistics Functions using SQL Server Data

Additional Articles from SQLServerCentral

Learn how to use statistical functions in Python with data from a SQL Server database along with several different examples.

Blog Post

From the SQL Server Central Blogs - Power BI: Dynamically Removing Errors From Columns in M

DataOnWheels from DataOnWheels

If you have excel data, or user-entered data, you have likely experienced frustration from repeatedly seeing the error message below upon hitting “Close & Apply” or refreshing your data...

Blog Post

From the SQL Server Central Blogs - Storing sp_BlitzIndex to a Table Between Reboots

Tracy Boggiano from Database Superhero’s Blog

I mentioned in my New Database Job – The 90 Day Plan blog how I have a trick for storing index usage stats up until close to the next reboot...

 

 Question of the Day

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

 

Consistent Time

I have two databases on two different instances. One is in London and one is in New York. Customers log data into these two databases in a table that captures the time that the client inserted the data. All this data is exported into a data warehouse for later analysis. I want to set a default on the table for a column that will automatically capture the time the insert took place, in either location, but in a consistent way. Meaning that if one insert takes place in London at 12:00pm, another takes place in London at 12:02pm, and a third takes place in New York at 7:01am, these are properly ordered. With New York five hours behind, this would mean the data warehouse would have the first London insert, the New York insert, and the second London insert in that chronological order. What should me default be for the column in this table if I want the most precision?

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)

DATETRUNC

In SQL Server 2022, there is a new T-SQL function, called DATETRUNC(). What does this do?

Answer: This removes all values up to a specified part of the datetime value

Explanation: This funciton allows you to truncate down to a particular part of the datetime value. You can truncate to seconds, minutes, hours, days, months, years, quarters, weeks, and more. Everything up to this datepart passed in is kept. Everything after is set to 0. Ref: Datetrunc() - https://docs.microsoft.com/en-us/sql/t-sql/functions/datetrunc-transact-sql?view=sql-server-ver16

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
AG issue - Few databases  are not in sync  in an AG   as we did not find  any  errors on secondary  replica . any query  to check the  last log backup  on secondary  server  and databases are in huge size  (1TB).  How to resync  database with primary  with out  dropping and adding  database in  primary  by  restoring full […]
Blocking with replication monitor - Hi SQL Experts, I opened the  replication monitor. I noticed it is causing frequent blocking. When I noticed it is showing create index statements but I didn't create any indexes. What it will happen when you open the replication monitor & why it is causing blocking?
Log backup job running long time - Hi, We have log backup job running daily 5 times. One time run is taking 4-5 times longer than the other runs daily. The backup size is same for all runs. How can we identify why it is taking long time for that particular time? We have DBCC check job scheduled 2hr before that log […]
Anonymus user for existing login in SSAS profile - Hi, We have SSAS installed. It is connecting remotely and loosing connection the connection immediately. When I run the profiler when it is first connected it is using the credentials and showing the permissions as OLAPdatareader in the profiler but immediately it is showing as anonymous user in the profiler and lost the connection to […]
SQL Server 2017 - Development
Archiving big table - Hey All, We have a very big table which stores transaction data and it is SCD Type 2 table. Records are identified by ID and effective date columns, primary key on these two columns. Table has grown close to 500GB in size with 1.4billion records.  2years ago we had moved records older than 2018/03 to […]
SQL Server 2016 - Administration
Permissions for a login - We have a login with a db_datareader only permissions. However, this login cannot see stored procedures in SSMS object explorer and cannot select from sys.procedures (only built-in diagram-related sp are listed there). What extra permissions should we give to a login to be able to see all stored procedures (not to execute them) and still […]
SQL Server 2016 - Development and T-SQL
Missing Data(finding the root problem) - I have this function running(see code). I would like to select data beteen dates e.g 30-06-2022 to 31-07-2022. Specificaly for columns Eligible, Fuel Levy, Claimable and % Eligible of purchase. I am gettig zero for these columns. Is my code the reason i am getting these errors or my data missing. More of the views/tables […]
Development - SQL Server 2014
SQL Using a PIVOT to Convert row data to column - Hello, Im trying to get a Pivot to work , but its retuning a NULL . I tried various thing , like using Partition with Row_number as well , the below is the scipt but return null. Basically, I'm looking for the Meshtype  to be the column    i.e Fine, coarse and Dry to be […]
SQL 2012 - General
MS SQL Server 2012 Bible, any opinions on this book? - Hello, the book MS SQL Server 2012 Bible is on O'Reilly's daily deal and I was wondering if anyone had any opinions or thought on it. I have been learning how to work SQL queries and databases at work for a project and am trying to decide if this book is worth buying.
SQL Server 2019 - Administration
Command-line installation failure - Detail.txt in use - Hi. I'm having a problem (on 2 different servers) performing a command-line install of SQL2019 with the error: The process cannot access the file 'C:\Program Files\Microsoft SQL Server\150\Setup Bootstrap\Log\20220802_031252\Detail.txt' because it is being used by another process. Any ideas what might be causing this? Thanks.
SQL Serer 2019 Mikn Worker Thread Calculations - I have looked at Max Worker Threads for SQL Server Always on Availability Group databases And AlwaysOn Availability Groups: What not to do when adding databases I'm trying to calculate minimum required worker threads on the primary using this formula: SELECT AG = D * (LCWT + (LSWT * SRC)) +MHWT Knowing that I have […]
SQL Server 2019 - Development
Count a new field in SQL statement - Hello all, I am trying to find a query that bring results like on the example. Thanks a lot all and best regards,
Calculate a new field in SQL statement - I have need calculate new field on this logic Is there way to do in SQL instead of procedure or function We have invoice id and item line item and we have credit memo which apply to line item Line Item 1 = 2098.76 Line Item 2 = 699.59 Apply CM Amount -2798.35 to both […]
SQL Azure - Administration
Password management in SQL MI for Sysadmin account - Hi, I've a requirement to provide temporary access for a sysadmin account. Each time a user requires access, temporary password needs to be created for the specific login. I've heard Password management tools like Cyberark can be used for it. Is there an inbuit tool for SQL MI password management or any open source tool […]
Amazon AWS and other cloud vendors
New to AWS - I am very new to AWS and trying to figure out how to do a few things but I am getting a bit overwhelmed. I have code that I put on an EC2 instance and it is connected to RDS. I can look up the EC2 generated url and see the data I expect to […]
 

 

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

 

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