Forum Widgets
Latest Discussions
Stored Procedure runs long the first run, then runs faster
I have a Stored Procedure that does the following: Creates 2 Temp Tables Inserts into first Temp Table Inserts into second Temp Table from 20 Tables, plus joining to the first Temp Table and has 10 subqueries. Inserts into second Temp Table from 18 Tables. Inserts into second Temp Table from 14 Tables. The first time the SP is run for the day, or after it has not run for a few hours, it sure 40+ seconds. The runs after that come in between 7 – 20 seconds. The SP takes three parameters which can change, but for testing we are using the same three parameters. The SP is in cache before the first run. I have checked all the Indexes are in place and not overly fragmented. I do not see any CPU, Memory, or Drive issues. I have gone through the Execution Plan more times that I can count. I do not understand why the first run takes long, but the following runs are always short. I did see this in another post: "A result set is never cached in SQL Server, however, the underlying data pages containing the result rows are. All this means is that the response time for subsequent queries may be lower since the underlying data is re-read from memory, with only any variations read from storage." If that is the issue, is there a way to "fix it"? Any ideas?RandyLP7May 23, 2025Copper Contributor12Views0likes1CommentSQL Server - SOS_SCHEDULER_YIELD and Unbalanced NUMA Node Usage
Hi everyone, we've faced an unusual behavior on our SQL Server and would like to understand the cause and how to manage it properly. Our DB Server is a physical server with 64 cores (128 logical CPUs) and 4 NUMA nodes. During a peak in application requests/session, we noticed a significant increase in SOS_SCHEDULER_YIELD waits, with an unusual distribution of CPU load: only 2 NUMA nodes were heavily saturated, while the others remained underutilized. Our main questions are: At what point does SQL Server assign the execution NUMA node to a session/process? During connection establishment? When the statement starts executing? If processor affinity is left at its default setting (not manually configured at the instance level), what metrics can we monitor to better understand and manage this behavior? Any insights or experiences with similar cases would be greatly appreciated. Thanks in advance!StefanoPMay 22, 2025Copper Contributor95Views1like2CommentsSQL Server 2025 Preview uninstalling
How can I uninstall SQL Server 2025 Preview safely (without affecting any other SQL Server versions)?tommerfrancisMay 22, 2025Copper Contributor13Views0likes1CommentInstalation problem SQLServer 2019/2022 on Win11Pro
Hi everyone, I'm writing here for the first time because I ran out of ideas. I had a working SQLServer Express 2019 (CU13) on Win10Pro machine. For educational and development purposes, local instalation, nothinng special. Recently, I upgraded Win10Pro to Win11Pro. The SQLServer service stopped working immediately. I tried everything to start the service but no luck. The next thing I tried was uninstall SQLServer2019 and install new one (2022 and 2019, same thing). At the end of the instalation, both give me the same error: TITLE: Microsoft SQL Server 2022 Setup ------------------------------ The following error has occurred: The filename, directory name, or volume label syntax is incorrect. Error code: 0x84BB0001 I searched all over the Internet and tried: Uninstall SQLServer and all components, delete all folders related with SQLServer Clean the registry keys and values related to SQLServer manually and check with CCleaner Check fsutil fsinfo sectorinfo C:, and it is fine (512/4096) Tried sfc, d*ism, chkdsk - all ok Download new ISO installation (2022 and 2019), mount setup.exe - Run as Administrator Disable firewall, antivirus, Defender Tried installing under the default directory name and the short one, changed instance name Create new local admin user and install under the new user Nothing helps. The error is the same whatever I do or install 2019 or 2022 version. Checked error log - can't find anything to guide me to the solution. Checked Global Rules - it's fine The SSD that I have is (the same SSD as on Win10 where everything worked): SCSI\DiskNVMe____SAMSUNG_MZALQ512HBLU-00BL27L2QFXM7 SCSI\DiskNVMe____SAMSUNG_MZALQ512HBLU-00BL2 SCSI\DiskNVMe____SAMSUNG_MZALQ512FXM7 SCSI\DiskNVMe____SAMSUNG_MZALQ512 SCSI\DiskNVMe____ SCSI\NVMe____SAMSUNG_MZALQ512F NVMe____SAMSUNG_MZALQ512F GenDisk ...any ideas? TIA Mladencocka13May 21, 2025Copper Contributor1KViews2likes3CommentsIssue Truncating Table with Foreign Key Constraints in Microsoft SQL Server 2022
Hi everyone, I'm currently working with Microsoft SQL Server 2022, and I'm encountering an issue when trying to truncate a table. The error message I'm receiving is as follows: "Cannot truncate table because it is being referenced by a FOREIGN KEY constraint." To address this error, I attempted to use the following query: sp_msforeachtable "ALTER TABLE ? NOCHECK CONSTRAINT all" However, even after running this query, I'm still encountering the same error. Can anyone help me understand what I might be doing wrong or suggest an alternative solution to successfully truncate the table? Thank you!hemantinsnapsysMay 21, 2025Copper Contributor17KViews1like4CommentsHow can I continue using SQL Server 2025 Preview with full features after the 180-day trial ends?
undefinedtommerfrancisMay 21, 2025Copper Contributor27Views0likes1CommentLinked Server Selection Query Fails with "MS DTC has stopped this transaction"
Hi everyone, I’m currently setting up a Linked Server from our head office (server A) SQL Server to a subsidiary unit (Server B) SQL Server. The Linked Server connection tests successfully, and I can log into server A from server B and can using query. However, when I try to execute a query using a 4-part name through Linked server, I encounter the following error: Msg 8522, Level 16, State 3, Line 1 Microsoft Distributed Transaction Coordinator (MS DTC) has stopped this transaction. Environment Details: Head Office (server A) SQL Server: SQL Server 2008 R2 (already upgraded pack SP3) Windows Server 2012 TLS 1.2 enabled MS DTC service is turned on Subsidiary (server B) SQL Server: SQL Server 2016 Windows Server 2016 Standard (64-bit) TLS 1.2 enabled MS DTC service is turned on Networking: The B server connects via VPN to be on the same network as server A Ping and Telnet tests (IP and port) from both sides work fine SQL login from server A to server B(via IP and port) is successful USING PROVIDER: i have try to using SQLNCLI11 and MSOLEDBSQL, but both till error DTC. Linked Server test connection: Success Update, insert query: it's ok, but when i try selection query, i got error DTC has stop this transaction. example: SELECT * FROM [LinkedServerName].[DatabaseName].[dbo].table Has anyone faced a similar issue? Could this be a MS DTC configuration mismatch or network security/firewall/DTC port range issue? Any guidance on how to properly configure MS DTC across different servers/domains/VPNs would be highly appreciated. Thanks in advance!TIENHCMay 16, 2025Copper Contributor36Views0likes1CommentSqlPackage halts for 100 seconds without apparent reason
I am running sqlpackage tool version 162.3.566.1 in Docker container image mcr.microsoft.com/dotnet/runtime:6.0 and/or Ubuntu base image and there is very strange behavior. Overall it works fine. But for some reason I can't understand why it stops for 100 seconds. Diagnostic log looks like this: Microsoft.Data.Tools.Diagnostics.Tracer Information: 25 : 2024-09-06T13:42:34 : Perf: Operation ended (name, details, elapsed in ms): Updating database,,265 Updating database (Complete) *** HERE IT WAITS FOR 100 SECONDS WITHOUT ANY APPARENT REASON **** Successfully published database. Changes to connection setting default values were incorporated in a recent release. More information is available at https://aka.ms/dacfx-connection Microsoft.Data.Tools.Diagnostics.Tracer Information: 18 : 2024-09-06T13:44:14 : Time elapsed: 0:01:46.30. Time elapsed 0:01:46.30 Microsoft.Data.Tools.Diagnostics.Tracer Information: 0 : 2024-09-06T13:44:14 : SqlPackage completed Any idea what can be the culprit???michaeljurekMay 14, 2025Copper Contributor173Views0likes2CommentsGrant with Grant option not working
I have two server logins: OMEGACA and TEST ... and an ALL SERVER for LOGON trigger, as CREATE TRIGGER [OMEGACA_ACC] ON ALL SERVER WITH EXECUTE AS 'OMEGACA' FOR LOGON AS ............... OMEGACA has Server roles public and sysadmin. It is also owner of database OmegaCoreAudit. In this DB I have the OMEGACA schema and the following procedure to disable/enable the OMEGACA_ACC trigger USE [OmegaCoreAudit] GO /****** Object: StoredProcedure [OMEGACA].[P_SYS_MANAGE_ACC] Script Date: 5/10/2025 6:30:00 PM ******/ SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO CREATE PROCEDURE [OMEGACA].[P_SYS_MANAGE_ACC] ( @p_trigger_status int ) AS BEGIN set NOCOUNT ON; -- Check Trigger Status if @p_trigger_status = 0 begin DISABLE trigger OMEGACA_ACC on ALL SERVER; end else if @p_trigger_status = 1 begin ENABLE trigger OMEGACA_ACC on ALL SERVER; end else begin RAISERROR('Wrong Status 1/0 value !',16,1); end; END; I want user TEST to be able to exec this procedure to enable/disable the server trigger. I do NOT want to grant this user (TEST) the "CONTROL SERVER" directly ! So, I: 1. Grant CONTROL SERVER to OMEGACA login with "with Grant" option ! 2. Map TEST login to OmegaCoreAudit TEST user 3. Grant EXECUTE on [OMEGACA].[P_SYS_MANAGE_ACC] to TEST user. Now, when as TEST login I do call: USE [OmegaCoreAudit] GO DECLARE RC int -- TODO: Set parameter values here. EXECUTE RC = [OMEGACA].[P_SYS_MANAGE_ACC] 0 GO I do get error: Msg 1088, Level 16, State 120, Procedure OMEGACA.P_SYS_MANAGE_ACC, Line 21 [Batch Start Line 2] Cannot find the object "OMEGACA_ACC" because it does not exist or you do not have permissions. Question: How can I have TEST login exec procedure correctly ? best regards AltinakaraulliMay 13, 2025Brass Contributor40Views0likes1Comment
Resources
Tags
- Data Warehouse68 Topics
- Integration Services59 Topics
- sql server54 Topics
- sql44 Topics
- Reporting Services43 Topics
- Business Intelligence36 Topics
- Analysis Services33 Topics
- Business Apps22 Topics
- analytics22 Topics
- ssms15 Topics