242 questions with SQL Server | SQL Server Transact-SQL tags
Where in error
Hi everybody, I cannot find an error in a simple statement: DECLARE @myrowid INT; DECLARE SplitProviderCursor CURSOR LOCAL FORWARD_ONLY STATIC READ_ONLY FOR SELECT rowid , npi FROM #tmp_npi_list; OPEN…
SQL Server | SQL Server Transact-SQL
Where is an error?
Hi everybody, This simple code produces an error and I couldn't find it: DECLARE @myrowid INT; DECLARE SplitProviderCursor CURSOR LOCAL FORWARD_ONLY STATIC READ_ONLY FOR SELECT rowid , npi FROM #tmp_npi_list; OPEN…
SQL Server | SQL Server Transact-SQL
How to solve the occasional timeout issue?
I aim to identify the cause and address the issue where the SQL execution time of occasional program calls exceeds the program's timeout threshold within a certain period, such as one day, after a timeout occurs. May I ask how I should proceed? I have a…
SQL Server | SQL Server Transact-SQL
How to signing EKM providers for MsSQL Servers on Linux
getting error Failed to get verify Authenticode signature on DLL while creating cryptographic provider on SQL server on Linux need solution
SQL Server | SQL Server Transact-SQL
Implementing User-Defined Sort via Trigger
Hi, Running SQL Server 2008 R2. We have a requirement to implement an arbitrary sort for a table using a numeric sort column. DDL and DML below: CREATE TABLE [dbo].[Test] ( [TestID] [bigint] IDENTITY(1,1) NOT NULL, …
SQL Server | SQL Server Transact-SQL
SPLIT_String is not recognized function name in SQL 2022
Good day, In SQL Server 2022 split_sting function shows with red underline like it doesn't exist. This statement SELECT v.value FROM #FirstResult CROSS APPLY SPLIT_STRING(Prov_Last_Name,'') AS v returns this error: Msg 208, Level 16, State 1,…
SQL Server | SQL Server Transact-SQL
SQL Server Database Engine error during insert/update sequence in employee audit table
I was running a SQL Server test for an internal employee-audit scenario. The script creates two tables, inserts a few rows and performs joins/updates. Expected: All inserts and updates should complete successfully. Observed: Several statements fail…
SQL Server | SQL Server Transact-SQL
Identity Column jumps massively from 168712 to 9999993
I have table with identity column id. There was massive jump from id 168712 to 9999993. It has happened twice in different servers. Its not identity cache/transaction rollback/manual insert/ reseed. Why its happening. Please guide me on this.
SQL Server | SQL Server Transact-SQL
SQL server 2022 job fails
Hello SQL Server 2022 16.0.4212.1 Installed in a windows server 2025 DC. SQLSERVERAGENT starts with NT Service\SQLSERVERAGENT I have some jobs that runs at the scheduled times. But one no. Failure: "Job failed. The job was invoked by Schedule 9…
SQL Server | SQL Server Transact-SQL
"SQL Server Database Engine Error while inserting and updating employee records in test environment"
I'm running a SQL Server test script that inserts employee data and performs several operations. Some statements work, but a few lines throw different errors — duplicate keys, missing columns, and invalid joins. Below is my script. Can anyone explain…
SQL Server | SQL Server Transact-SQL
how to modify index maintenance script
Hi Team, How to modify T-sql indexmaintenance script only do Index Reorganize
SQL Server | SQL Server Transact-SQL
Unexplainable results
Good day, I have a complex stored procedure. This procedure returns different results when I add extra condition for specific NPI vs returning without this extra condition. Automation OHCS Professional Rendering Yes OHCS Partial…
SQL Server | SQL Server Transact-SQL
SSMS V22 times out on large queries where v19 did no
Hello, I use my laptop with SQL Developer to prototype databases before publishing them on a live SQL server. My laptop crashed and I had to reinstall all of the software. In my old laptop I was using SQL Server v2016 (not sure about this version) and…
SQL Server | SQL Server Transact-SQL
SQL Server Error: Cannot insert duplicate key for EmployeeID
-- Step 1: Create Test Database CREATE DATABASE EmployeeDBTest2; GO -- Step 2: Switch to Database USE EmployeeDBTest2; GO -- Step 3: Create Employee Table CREATE TABLE Employees ( EmployeeID BIGINT NOT NULL PRIMARY KEY, Name NVARCHAR(100), varchar…
SQL Server | SQL Server Transact-SQL
How can I compare the Original T-SQL Script with the edited version of the same T-SQL
I thought Redgate and SQL Compare could compare two T-SQL scripts and highlight any changes, deltas for you...But I have no idea how to use that. I also know that there are some one-off T-SQL comparison software packages out there. Which would the forum…
SQL Server | SQL Server Transact-SQL
Always get latest score that is not 0 or null
Hi, I have a table like the below with scores. CREATE TABLE [dbo].[Student_Scores]( [Month] [int] NULL, [Student_no] [bigint] NULL, [Score] [numeric](18, 2) NULL ) ON [PRIMARY] GO INSERT [dbo].[Student_Scores] ([Month], [Student_no], [Score]) VALUES…
SQL Server | SQL Server Transact-SQL
Using a cutom policy file for Get-SqlSensitivityRecommendations
I'm trying to import a custom Information Protection Policy file into SSMS to add more patterns, mainly because I have a French audience, so most of the default terms don’t apply in my case. Since the interface works only for one database at a time and…
SQL Server | SQL Server Transact-SQL
Why this query produces an error?
Hi everybody, This this query produces an error ;WITH latestTermDate AS (SELECT MAX(status_date) AS dt, tin_number FROM #FirstResult GROUP BY tin_number UNION ALL SELECT MAX(hn.load_date) AS dt, tin…
SQL Server | SQL Server Transact-SQL
How to fix "Msg 11535, Level 16, State 1,"
I have a complex procedure returning one result set. However, when I execute using WITH RESULT SETS I'm getting this error: Msg 11535, Level 16, State 1, Procedure im_automation.accent_changes, Line 814 [Batch Start Line 0] EXECUTE statement failed…
SQL Server | SQL Server Transact-SQL
Where is dbo.indexoptimize procedure?
Hi, I have a SQL Server job with the step with the following code: EXECUTE [dbo].[IndexOptimize] @Databases = 'USER_DATABASES', @LogToTable = 'Y' Where is that procedure? I searched in msdb database and don't see it there.