249 questions with SQL Server | SQL Server Transact-SQL tags

Sort by: Updated
1 answer

Which T-SQL statement should be used to instruct a database management system to use an index instead of performing a full table scan?

Hello everyone, I am currently preparing for the DP-900: Microsoft Azure Data Fundamentals exam and would like to get an expert's clarification on a specific question. The question is as follows: Which T-SQL statement or clause should be used to…

SQL Server | SQL Server Transact-SQL
asked 2025-08-19T14:21:02.75+00:00
Anabella Noemi Santillan 0 Reputation points
commented 2025-11-21T12:14:50.85+00:00
Thumu Sai Pranay 0 Reputation points
2 answers

The audit for this user shows success, but when using SSMS, the error that is received is 18456 and he cannot sign in

We are using integrated security. All other users have no problem getting to this database. One user, gets and 18456 error. The user is part of the SQL Contributor Group. The activity logs for login shows successful login in SQL server through AD,…

SQL Server | SQL Server Transact-SQL
asked 2025-11-18T17:49:45.6+00:00
Patrick Dengler 0 Reputation points
answered 2025-11-19T12:17:48.7633333+00:00
Shruti Dhruv 250 Reputation points Microsoft External Staff Moderator
2 answers

DBCC TRACEOFF 3604

Good afternoon SQL 2022 Standard I would like to better understand: DBCC TRACEOFF 3604 DBCC TRACEON 3604 How to use it? How to activate it? How and when should it normally be used? Thank you Urantia

SQL Server | SQL Server Transact-SQL
asked 2025-11-18T14:52:31.8666667+00:00
Urantia 0 Reputation points
commented 2025-11-18T21:04:53.9233333+00:00
Urantia 0 Reputation points
1 answer

I created connections via mssql extension in vs code and now when I click on mssql, I don't see them.

I saved database connections in via mssql extension in vs code and now when I click on mssql, I don't see them. All I see when I click on the mssql icon is this.

SQL Server | SQL Server Transact-SQL
asked 2025-07-25T20:19:25.4233333+00:00
Amy Petrone 0 Reputation points
commented 2025-11-18T09:15:43.0933333+00:00
Nithin Krishna Madadi 0 Reputation points Microsoft External Staff Moderator
1 answer

4K supported Disk is the new one. But still in the Windows 11 Pro with 4K disk doesn't support SQL 2022 or 2019 express edition. What is the solution for that?

It is limitation or any specific concern. I can not install 2019/2022 express in my laptop which disk is 4K -native. Whats should be the solution?

SQL Server | SQL Server Transact-SQL
asked 2025-08-20T08:53:06.43+00:00
Sandip Patel 0 Reputation points
commented 2025-11-17T15:44:19.7266667+00:00
Erland Sommarskog 128.4K Reputation points MVP Volunteer Moderator
1 answer

Tools for SQL Query Tuning

Hi Expert, What is tool for tuning the SQL Query? I need to checking the query that take long time in running thanks for all valued information warm regards, Urbel

SQL Server | SQL Server Transact-SQL
asked 2025-11-13T03:46:44.3733333+00:00
UrBel 300 Reputation points
commented 2025-11-17T11:16:46.9633333+00:00
Lakshmi Narayana Garikapati 640 Reputation points Microsoft External Staff Moderator
0 answers

Raiserror doesn't output messages

Hi everybody, I have a strange problem. I have a long procedure which has 2 places that send notes for other procedure. This procedure outputs NULL by this line of code: DECLARE @message VARCHAR(200) = ' Notes is ' + ISNULL(@notes, 'NULL') RAISERROR…

SQL Server | SQL Server Transact-SQL
asked 2025-11-03T13:53:02.7566667+00:00
Naomi Nosonovsky 8,881 Reputation points
commented 2025-11-17T10:39:13.8133333+00:00
Lakshmi Narayana Garikapati 640 Reputation points Microsoft External Staff Moderator
3 answers

How to find Missing non clustered Indexes

Is there way to find Missing non clustered Indexes on Particular Database? Thank you

SQL Server | SQL Server Transact-SQL
asked 2025-08-12T15:50:01.7033333+00:00
Jinal Contractor 121 Reputation points
commented 2025-11-14T08:07:56.22+00:00
Singam shetty Sri ganesh 80 Reputation points Microsoft External Staff Moderator
1 answer

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
asked 2025-10-17T16:06:46.38+00:00
Perumal, Gowthami 5 Reputation points
commented 2025-11-10T12:14:48.2966667+00:00
Perumal, Gowthami 5 Reputation points
2 answers

Sql 2025 T-SQL Job

SQL 2025 Std running in a Windows server 2022 Std A job with a T-SQL task (which calls a stored procedure) ran well weekly for almost a month, at a specific time of day For various reasons, I had to change it so that it would run at a different time of…

SQL Server | SQL Server Transact-SQL
asked 2025-11-09T17:54:49.8566667+00:00
Delmira Oliveira 100 Reputation points
edited an answer 2025-11-09T22:04:33.5733333+00:00
Erland Sommarskog 128.4K Reputation points MVP Volunteer Moderator
1 answer One of the answers was accepted by the question author.

Why would this statement produce Primary Key violation error?

Hi everyone, Why would this code produce primary key violation error? DROP TABLE IF EXISTS #temp SELECT TOP (1000) indiv.npi, TRIM(lastname +', '+ firstname + ' ' + LEFT(middlename, 1)) AS fullname, firstname, lastname, LEFT(middlename, 1) AS…

SQL Server | SQL Server Transact-SQL
asked 2025-11-09T20:46:33.1966667+00:00
Naomi Nosonovsky 8,881 Reputation points
commented 2025-11-09T21:12:02.29+00:00
Naomi Nosonovsky 8,881 Reputation points
1 answer

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
asked 2025-10-24T04:01:01.9066667+00:00
Pradip Chahande 0 Reputation points
commented 2025-11-06T09:01:36.5533333+00:00
Lakshmi Narayana Garikapati 640 Reputation points Microsoft External Staff Moderator
0 answers

Invalid object name cte

Hello everyone, Why invalid object name cte appears on the second line in this valid query in run-time: SELECT 'Automation OHCS' AS source, cte.Request_Type, cte.Change_Type, cte.[Exclusion_Reason], --…

SQL Server | SQL Server Transact-SQL
asked 2025-08-19T16:18:51.7433333+00:00
Naomi Nosonovsky 8,881 Reputation points
commented 2025-11-05T08:52:33.38+00:00
Singam shetty Sri ganesh 80 Reputation points Microsoft External Staff Moderator
0 answers

The query processor ran out of internal resources and could not produce a query plan. This is a rare event and only expected for extremely complex queries or queries that reference a very large number of tables or partitions. Please simplify the query. If

Good day, I am getting this error: The query processor ran out of internal resources and could not produce a query plan. This is a rare event and only expected for extremely complex queries or queries that reference a very large number of tables or…

SQL Server | SQL Server Transact-SQL
asked 2025-08-04T22:07:12.9+00:00
Naomi Nosonovsky 8,881 Reputation points
commented 2025-11-05T08:52:11.6666667+00:00
Singam shetty Sri ganesh 80 Reputation points Microsoft External Staff Moderator
0 answers

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
asked 2025-09-11T07:43:40.6466667+00:00
Delmira Oliveira 100 Reputation points
commented 2025-11-04T21:45:06.9766667+00:00
Delmira Oliveira 100 Reputation points
1 answer One of the answers was accepted by the question author.

Where is an 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
asked 2025-10-26T15:20:31.68+00:00
Naomi Nosonovsky 8,881 Reputation points
commented 2025-11-03T19:45:06.7166667+00:00
Naomi Nosonovsky 8,881 Reputation points
1 answer

Temp Table and Temp DB Space issues

We are recently having issues with Temporary Tables and Temp space failing on some of our jobs. We have asked our DBA if increasing Temporary space and Temp DB is an option and apparently it is not as Temp Space is already allocated fairly high. Just…

SQL Server | SQL Server Transact-SQL
asked 2025-10-28T14:45:59.14+00:00
Bobby P 231 Reputation points
commented 2025-11-03T17:22:40.3366667+00:00
Lakshmi Narayana Garikapati 640 Reputation points Microsoft External Staff Moderator
1 answer One of the answers was accepted by the question author.

Strange output of the procedure

Hi everybody, I have a stored procedure and I'm puzzled by its output. ```tsql CREATE OR ALTER PROCEDURE [dbo].[usp_Exclude_Mission_Act_Providers] @inp_process_txt VARCHAR(50) = '' , @inp_lcd_id INT = 0 , @inp_job_nbr TINYINT = 30 ,…

SQL Server | SQL Server Transact-SQL
asked 2025-10-30T14:14:45.3966667+00:00
Naomi Nosonovsky 8,881 Reputation points
accepted 2025-11-03T13:33:59.6066667+00:00
Naomi Nosonovsky 8,881 Reputation points
1 answer

select query

declare @tmp table ( id INT IDENTITY(1,1), Summary varchar(500), type varchar(10), filename varchar(500) ) INSERT INTO @tmp select 'xxx', 'PDF', 'FileName1' union all select 'yyy', 'PDF', 'FileName2' union all Select 'yyy', 'MSG', 'filename3' union…

SQL Server | SQL Server Transact-SQL
asked 2025-09-05T17:23:44.97+00:00
Spunny 366 Reputation points
commented 2025-11-01T07:20:08.1933333+00:00
Thumu Sai Pranay 0 Reputation points Microsoft External Staff Moderator
1 answer

Is this correct SQL query related forum

Hi Just wondering if this is the forum where I can ask SQL queries related questions? Sorry bit confused between other Tech forum.

SQL Server | SQL Server Transact-SQL
asked 2025-09-07T10:38:14.43+00:00
LathaSree 5 Reputation points
commented 2025-11-01T07:19:19.0533333+00:00
Thumu Sai Pranay 0 Reputation points Microsoft External Staff Moderator