|
|
|
|
|
|
|
Question of the Day |
Today's question (by Steve Jones - SSC Editor): | |
Which MAXDOP? | |
I have a SQL Server 2022 instance with this setting:
EXECUTE sp_configure 'max degree of parallelism', 4; GOI then run this: SELECT ProductID, OrderQty, SUM(LineTotal) AS Total FROM Sales.SalesOrderDetail WHERE UnitPrice < $5.00 GROUP BY ProductID, OrderQty ORDER BY ProductID, OrderQty OPTION (MAXDOP 2); GOWhat is the maxdop for my query? | |
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) |
Detecting Multiple Changes I want to write a trigger to detect changes to columns in SQL Server 2022. I have this table: CREATE TABLE CustomerLarge (CustomerID INT NOT NULL IDENTITY(1, 1) CONSTRAINT CustomerLargePK PRIMARY KEY CLUSTERED , CustomerName VARCHAR(20) , CustomerContactFirstName VARCHAR(40) , CustomerContactLastName VARCHAR(40) , Address VARCHAR(20) , Address2 VARCHAR(20) , City VARCHAR(20) , CountryCode CHAR(3) , Postal VARCHAR(20) , creditlimit INT , discount NUMERIC(4, 2) , lastorderdate DATETIME , lastorderamount NUMERIC(10, 2) , lastordercontact VARCHAR(20) , created DATETIME , modified DATETIME , modifiedby VARCHAR(20) , statusid INT , active BIT , customersize INT , primarysalesid INT); GO I want to determine if both the CustomerContactFirstName and CustomerContactLastName fields are changed, but no others. What is the mask I need to use with COLUMNS_UPDATED()? Answer: IF (SUBSTRING(COLUMNS_UPDATED (),1,1) & 12) = 12 Explanation: In testing, I found I needed to use the SUBSTRING) function or the bitwise math doesn't work. In this case, to check two columns, I need both bitmasks to be set. These are the 3rd and 4th columns, so the 4 and 8 places in binary. Adding these together gives me 12 and I need an exact match. A > 12 means other columns were updated as well. Ref: COLUMNS_UPDATED() - https://learn.microsoft.com/en-us/sql/t-sql/functions/columns-updated-transact-sql?view=sql-server-ver16 |
Featured Script |
Cleanup backup file folder future 7 days Srinivas Merugu from SQLServerCentral Two PowerShell scripts to create backup folders and clean up old files.
|
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 2019 - Administration |
Best Practices when a TempDB Drive is full? - Good morning. I've recently started a new SR. DBA position. I have been hit with a lot of things in this last month. I recently found a server that had the TempDB drive full. I wanted to resize the files to take up only 80% of the drive and leave 20% for the OS processing. […] |
RCSI vs. tempdb placement for mixed OLTP + heavy afternoon reporting (SQL 2019) - We upgraded an application and are seeing performance issues. The vendor suggests enabling READ_COMMITTED_SNAPSHOT (RCSI) to “improve performance.” Symptoms: performance degrades in the afternoon when there’s more reporting/querying against the production database. Reports are data heavy. We don’t yet have a separate reporting server, but that’s likely coming. Questions: If we move tempdb to its […] |
SQL Server 2019 - Development |
need to find rows in a table based upon a type field BUT stop when a select type - i have a table account number, date, type, amount 0000001, 20250815, P, 200.00 0000001, 20250810, C, -125.00 0000001, 20250801, C, -75.00 0000001, 20250725, C, -125.00 0000001, 20250720, P, 175.00 ...... i need the query to stop when it finds the first P type after the first one. so i would get 0000001, 20250815, P, 200.00 […] |
Reporting Services |
2 table designs within one section to keep data for one section value within one - My requirement is to display data for a number of routes within 2 tables and keep everything in one page where each value for the route generates a new page. I have created a group for route calling it 'sectie1' and set proper behavior for this sectie (page break, having headers on each page etc). […] |
Editorials |
Why Tech Events Matter for Data Pros (and why I’m grateful) - Comments posted to this topic are about the item Why Tech Events Matter for Data Pros (and why I’m grateful) |
Your Favorite Improvement - Comments posted to this topic are about the item Your Favorite Improvement |
T-SQL |
Backup information incorrect after AAG toggle - Good morning all, I have the attached T-SQL query that has been working well for sometime. This past Saturday during patching, the AAG toggled from primary on server1 to primary on server2. Now the query does not report differentials from the current primary server. Any pointer/suggestions on what I fail to see is greatly appreciated. […] |
Backup information incorrect after AAG toggle - Good morning all, I have the attached T-SQL query that has been working well for sometime. This past Saturday during patching, the AAG toggled from primary on server1 to primary on server2. Now the query does not report differentials from the current primary server. Any pointer/suggestions on what I fail to see is greatly appreciated. […] |
Article Discussions by Author |
Using psycopg2 to Connect Python to PostgreSQL - Comments posted to this topic are about the item Using psycopg2 to Connect Python to PostgreSQL |
From Rows to Pages: The Hidden Chaos Behind SQL Server’s Sampling Methods - Comments posted to this topic are about the item From Rows to Pages: The Hidden Chaos Behind SQL Server’s Sampling Methods |
SQL Server 2022 - Development |
ssms aborting in object explorer details - Hi i just set up a new pc after my touch pad went bad. our tech guy installed a version of ssms that says its this SQL Server Management Studio 21.4.12+5.36408.4. its not the version i used before. I'm not 100% certain what image he uses to set up a new pc. I'm getting the […] |
How to Resolve SQL Server Error 9100? - Is there any professional method to resolve SQL server error 9100. |
how does report builder play with dev ops - Hi as i prepare for using source control, it occurs to me report builder is the most common way we edit and save reports to ssrs. Is there a hook into dev ops from report builder when a developer prefers RB for ssrs modification? or will we need to get vs involved also after the […] |
having the right GIT (or whatever) for when i clone repos from devops - Hi, i'm getting set up to begin using dev ops for source control over lots of dev types of objects including ssis, db objects etc etc. My understanding is that if i want to use that familiar gui experience where after you clone a repo and want to just click (instead of issuing git commands […] |
thought i installed ssis extension in vs2022 but got sql server database project - Hi I dont think i'm crazy. I had to get a new pc. And reinstalling vs extensions unfortunately became my dreaded nightmare once again. I went to extensions in vs, manage extensions, chose sql server integration services project 2022, followed all the prompts , restarted the pc and saw what you see below. i'm back […] |
| |
©2019 Redgate Software Ltd, Newnham House, Cambridge Business Park, Cambridge, CB4 0WZ, United Kingdom. All rights reserved. webmaster@sqlservercentral.com |