Problems displaying this newsletter? View online.
SQL Server Central
Featured Contents
Question of the Day
 
 
 
 Featured Contents
SQLServerCentral Article

The Paradox of NOLOCK: How Dirty Reads Can Sometimes Be Cleaner

omu from SQLServerCentral

Every SQL Server developer has heard it: "Don't use NOLOCK in production!" But this common rule isn't as simple as it seems. Sometimes, what seems like a bad practice can actually be the right choice. Let's explain what NOLOCK really does in simple terms. When you use NOLOCK, you're telling SQL Server "just show me […]

External Article

3 Legit Signs It’s Time for Enterprise Edition

Additional Articles from Brent Ozar Blog

Your app is happily humming along on SQL Server Standard Edition. Things are quiet – too quiet. You’re wondering what you’re missing, and whether you should be on SQL Server Enterprise Edition. Here are 3 warning signs to watch out for.

Blog Post

From the SQL Server Central Blogs - Finding fields used in a Power BI report in PBIR format with Semantic Link Labs

Meagan Longoria from Data Savvy

Have you ever wondered where a certain field is used in a report? Or maybe you need an easy way to find broken field references in a report? Certain...

Blog Post

From the SQL Server Central Blogs - Adding Test data to msdb.sysjobhistory

Steve Jones - SSC Editor from The Voice of the DBA

One of our internal people was looking to test some process in (I assume) Redgate Monitor and needed more job history than they had in msdb.sysjobhistory. They wanted to...

Pro T-SQL 2022: Toward Speed, Scalability, and Standardization for SQL Server Developers

Site Owners from SQLServerCentral

Learn how to write and design simple and efficient T-SQL code. This is a hands-on book that teaches you how to write better T-SQL with examples and straightforward explanations.

 

 Question of the Day

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

 

Getting ANY of the data

I have this data in two tables:
-- Beer table
BeerIDBeerNamebrewer
5Becks    Interbrew
6Fat Tire   New Belgium
7Mac n Jacks  Mac & Jack's Brewery
8Alaskan AmberAlaskan Brewing 
9Kirin        Kirin Brewing

-- Beercount table
BeerName      BottleCount
Becks         5
Fat Tire      1
Mac n Jacks   2
Alaskan Amber 4
NULL          7
Corona        2
Tsing Tao     4
Kirin         12
What is returned from this query?
SELECT *
FROM dbo.BeerCount AS bc
WHERE bc.BeerName=ANY
  (SELECT b2.BeerName FROM dbo.Beer AS b2);
 

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)

Subqueries II

What is wrong (if anything) with this code?

SELECT *
 FROM Sales.SalesOrderHeader AS soh 
 WHERE customerid IN (SELECT soh.CustomerID FROM Sales.Customer AS c WHERE soh.CurrencyRateID = 1 ORDER BY c.ModifiedDate)

Answer: There needs to be a TOP in the subquery

Explanation: A subquery can have an ORDER BY if there is a TOP clause (or OFFSET or FOR XML). Adding TOP lets this run. Now, the error is: Msg 1033, Level 15, State 1, Line 3 The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP, OFFSET or FOR XML is also specified. Ref: Subqueries - https://learn.microsoft.com/en-us/sql/relational-databases/performance/subqueries?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 2016 - Administration
Active and Active Cluster - Hi Team, I am planning to apply security updates for SQL Server 2016 on Active/Active Cluster servers. Could you please advise on the proper procedures to follow? Specifically, which server should I apply the updates to first, and when should I reboot the servers? Your guidance would be greatly appreciated.   Thanks
Tracing a performance issue - Edit: This is a duplicate of another post.
Tracing a performance issue - Hello, We have a SQL agent job that runs daily. It runs a procedure, which for the purposes of this post, I will refer to as 'Procedure A'. That procedure runs other procedures. Every few months we get an issue where it appears to have stalled. Task manager is showing the SQL Server process at […]
SQL Server 2016 - Development and T-SQL
identify consecutive records greater than 1 - Hello I need help identifying all records that have consecutive hours (time in order) of greater than 1 for the value field. The output I am looking for would have Number,Start Time,End Time, Average of val over that time range that is identified. create table LunchTable ( Number integer, Value decimal(15,2), StartTime datetime ); insert […]
Import data from json file with special characters - I am using the following script to import data from a json file. This file contains special characters for some names. Once imported, I noticed that sql server is replacing the special characters with some other ones. Is there away to import special characters without changing them? Any help is greatly appreciated. CREATE TABLE test3 […]
Administration - SQL Server 2014
SSIS package works in VS but failed in SSMS - Please help and thanks. Package:Error: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005. An OLE DB record is available.  Source: "Microsoft OLE DB Provider for SQL Server"  Hresult: 0x80004005  Description: "[DBNETLIB][ConnectionOpen (Connect()).]SQL Server does not exist or access denied.".  
SQL Server 2019 - Administration
SQL Server migration using replication - I've set up replication in my SQL 2019 environment in attempt to migrate SQL databases individually from one datacenter to another.  in my testing of one database several issues were found  and any advice would be appreciated. 1. There several missing indexes 2. very large tables cannot be filtered on for transaction replication(post snapshot migration) […]
Automating SQL Server 2019 Setup and Configuration Across Multiple Servers - Hi everyone, I’m looking to automate the installation and configuration of SQL Server 2019 on multiple servers in our environment. So far, I’ve been using tools like PowerShell scripting using scriptrunner, attune, pdqdeploy and dbatools for some tasks, but I’m curious if anyone has a full end-to-end solution they recommend. My main goals are: Automating […]
SQL Server 2019 - Development
Need a list of stored procedures that execute multiple stored procedures - Hello SSC! I hope you all had a happy and safe holiday! Apologies if this post is confusing... I have a bunch of procs that call an index rebuild proc multiple times based on column name. Basically, this is all hardcoded (I did not write this :)). I tried a bunch of scripts to identify […]
SQL Azure - Administration
Creating LS from IaaS to Paas using MFA - Guys - I need your help on this.... I like to create an linked server from an IaaS (VM) to a PaaS managed instance but when I heve to loging to the MI using MFA I have to respond using mij GSM ( entering a code to confirm it is me ). How can I […]
Integration Services
Call dynamic sql storedprocedure from SSIS execute sql task - hi, I have a table called Rules Create table Rules ( Id int , Rules Statement Nvarcahr(max) ) values Id   RulesStatement 1      Sp_execute_rules @job_id , @run_id,@createid   So , i will be passing the parameters from my ssis package and calling the storedprocedure. this is how i am calling in execute sql task […]
SQL Server 2022 - Administration
Migrating database with many orphan users. - I am currently upgrading a very old database running SQL Server 2008 to SQL Server 2022 using export & import method to a new server. I have migrated the necessary objects e.g. logins, linked servers & configuration to the new server successfully. For logins, I use revlogin procedure to script out all the logins from […]
Primary and Secondary Filegroup - Hello, I am having database primary and secondary filegroup. Few tables/indexes are partitioned on secondary filegroup for better performance. But when I check activity monitor, I always see MDF & LDF files having response times under the Data Fil I/O but there is always 0 response time for NDF. Is this normal behaviour of MSSQL? […]
SQL Server 2022 - Development
Cannot install development version. - A while into install I get a Microsoft OLE DB Driver for SQL Server. The feature you are trying to use is on a network resource that is unavailable. It is looking for msoledbsql.msi. I have one locally but than I get a message: The file 'D:\msoledbsql.msi' is not a valid installation package for the […]
sql query to check status change of an item - I have a table dbo.tblPresentationStatus (sql script attached - table script.txt) I have to select rows where the status change is wrong. (not as per the correct flow as shown in attached image status_Flow.jpg) From 'Review' the status for a specific presentation ID can change to either 'Approve' or 'Presentation' or 'Close' From 'Approve' the […]
 

 

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

 

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