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

Sort by: Updated
1 answer

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
answered 2025-08-12T21:02:27.78+00:00
Erland Sommarskog 124.3K Reputation points MVP Volunteer 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,451 Reputation points
commented 2025-08-05T23:53:30.99+00:00
Naomi Nosonovsky 8,451 Reputation points
1 answer One of the answers was accepted by the question author.

How to alter default_schema

Here's my problem: Logged into SQL Server with default Windows authentication, Username = [mydomain\CoreyF] Created a table "mytable" Executed "SELECT * FROM INFORMATION_SCHEMA.TABLES" The default schema shows…

SQL Server | SQL Server Transact-SQL
asked 2025-08-01T19:14:09.6033333+00:00
Corey Fleig 100 Reputation points
commented 2025-08-02T00:20:02.82+00:00
Corey Fleig 100 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
edited an answer 2025-07-25T21:40:32.1933333+00:00
Bruce (SqlWork.com) 79,101 Reputation points Volunteer Moderator
2 answers One of the answers was accepted by the question author.

Missing column values

Hi, I have sample student data as in the below. CREATE TABLE [dbo].[test_table]( [ID] [bigint] NULL, [Score] [numeric](38, 6) NOT NULL, [Ratio] [numeric](38, 6) NOT NULL, [Desc] [varchar](50) NULL, [Report] [varchar](8) NULL ) ON…

SQL Server | SQL Server Transact-SQL
asked 2025-07-24T04:52:41.85+00:00
Rontech10111 181 Reputation points
accepted 2025-07-24T11:47:58.9966667+00:00
Rontech10111 181 Reputation points
1 answer One of the answers was accepted by the question author.

How to update existing columns during insert

Greetings! I have a SQL job that runs the following SQL script every Monday. WITH Result1 AS ( select p.Customer, p.ProductNumber, p.CurrentCost from price p ) --Main Select insert into Price_Archive ( [DateTime], [Customer], [ProductNumber],…

SQL Server | SQL Server Transact-SQL
asked 2025-07-23T13:13:29.74+00:00
Mizuno8482 20 Reputation points
commented 2025-07-23T14:54:22.56+00:00
Mizuno8482 20 Reputation points
2 answers

Latest security update has caused SS debugger to fail... 2008 r2 windows 10 - Windows Firewall

Getting: The WIndows Firewall on this machine is currently blocking remote debugging. RD requires... TCP Port 135... UDP 4500/ 500 be unblocked. Can't Cancel, Unlock for local or Unlock for Computer. Trying to "Debug>Start Debugging".

SQL Server | SQL Server Transact-SQL
asked 2025-07-12T01:50:50.6933333+00:00
M Douglas Martin 0 Reputation points
commented 2025-07-17T18:06:02.4033333+00:00
M Douglas Martin 0 Reputation points
1 answer One of the answers was accepted by the question author.

need a query for a match 2

Hi all, I have these two tables: T1 Date Item Qty 2025-07-01 100 10 2025-07-01 101 20 2025-07-01 102 20 2025-07-01 105 30 2025-07-02 100 30 2025-07-03 200 20 2025-07-03 201 25 2025-07-03 202 40 2025-07-04 200 30 and T2 Date …

SQL Server | SQL Server Transact-SQL
asked 2025-07-11T18:10:16.52+00:00
elsvieta 416 Reputation points
commented 2025-07-15T12:28:08.22+00:00
elsvieta 416 Reputation points
1 answer

Assigning large text block to nvarchar(max) SOMETIMEs truncates at 4000 bytes

I have a really large dynamic sql query (19,000+ in length) that is assigned to @SQLText nvarchar(max). Everything was working. Made some minor changes and then @SQLText variable only contained 4000 characters, truncating the rest of the query text.…

SQL Server | SQL Server Transact-SQL
asked 2025-07-14T15:30:33.5+00:00
Grossnickle, Brenda 120 Reputation points
commented 2025-07-14T16:53:33.51+00:00
Grossnickle, Brenda 120 Reputation points
1 answer One of the answers was accepted by the question author.

need a query to do a match

Hi all, I have these two tables: T1 Date Item Qty 2025-07-01 100 10 2025-07-01 101 20 2025-07-02 100 30 2025-07-03 200 20 2025-07-04 200 30 and T2 Date Item …

SQL Server | SQL Server Transact-SQL
asked 2025-07-09T15:21:43.62+00:00
elsvieta 416 Reputation points
commented 2025-07-11T17:43:53.7433333+00:00
elsvieta 416 Reputation points
1 answer

Documentation for CLR-Based Alternatives to xp_cmdshell

Hi Team, Since extended stored procedures are deprecated, is there any source code or documentation available for a CLR-based alternative to Microsoft system-defined extended stored procedures such as xp_cmdshell? Thanks, Abhishek Modi

SQL Server | SQL Server Transact-SQL
asked 2025-07-08T06:13:40.6066667+00:00
Abhishek Modi (amodi) 0 Reputation points
commented 2025-07-09T07:52:15.66+00:00
Erland Sommarskog 124.3K Reputation points MVP Volunteer Moderator
1 answer

Power Apps SQL Update Taking Time – Need Help with Efficient Bulk Update via Staging Table and Dynamic SP.

Question: We are currently using Power Apps to perform manual data reconciliation between two tables — let’s say TBL-1 and TBL-2 (as shown in the screenshot below). Our users upload data from Excel via Power Apps and click “Update,” which triggers SQL…

SQL Server | SQL Server Transact-SQL
asked 2025-07-07T15:56:38.7+00:00
Dheeraj Singh 0 Reputation points
answered 2025-07-07T20:12:59.29+00:00
Erland Sommarskog 124.3K Reputation points MVP Volunteer Moderator
2 answers

Issue with SQL Azure Secure Enclave: LIKE Clause Failing with Error".

I am using Microsoft SQL Azure (RTM) - 12.0.2000.8 , where I configured the secure enclave with VBS where I am using keyvalut for creating column master key. All the operators are working fine except like. Able to insert, update with where clause. Tried…

SQL Server | SQL Server Transact-SQL
asked 2025-06-05T09:44:00.5466667+00:00
Ashish Singhal 0 Reputation points
commented 2025-06-09T21:09:32.73+00:00
Erland Sommarskog 124.3K Reputation points MVP Volunteer Moderator
1 answer One of the answers was accepted by the question author.

Regarding the stability of the execution plan generation

My English is not good, so I use a translator to communicate. Please excuse me if it's not accurate I'm optimizing an sql,I created a few indexes, and the cost exceeded the parallel threshold, and it reported that the optimization was prematurely…

SQL Server | SQL Server Transact-SQL
asked 2025-06-06T06:58:03.05+00:00
博雄 胡 685 Reputation points
accepted 2025-06-09T03:33:17.3766667+00:00
博雄 胡 685 Reputation points
2 answers

Using IsNull with different data types in SQL SERVER

Hi Team, I am working on on premises SQL Server. I have a requirement where I need to apply left outer join between 2 tables and use IsNull to show default data when columns are having null. Under ISNULL, if a column is null what shall i put for below…

SQL Server | SQL Server Transact-SQL
asked 2025-06-06T18:06:46.15+00:00
Salil Singh 60 Reputation points
answered 2025-06-09T17:55:33.42+00:00
SUMIT RAY 0 Reputation points
0 answers

Execution of the stored procedure gives different result comparing with the direct execution

Hi everybody, I'm getting very puzzling results executing stored procedure vs executing subset of the code from that stored procedure directly. I have the following code to execute SP: DECLARE @RC INT DECLARE @inp_region_nbr TINYINT = 1 DECLARE @inp_npi…

SQL Server | SQL Server Transact-SQL
asked 2025-06-13T22:28:35.3266667+00:00
Naomi Nosonovsky 8,451 Reputation points
edited a comment 2025-06-15T03:41:40.6766667+00:00
Naomi Nosonovsky 8,451 Reputation points
1 answer

SQL Server 2019 Database Diagram Issue

hi, I am facing an issue that whenever I change some table relation or remove table from the database the database diagram containing that table shows blank page. I have used queries to check the database diagram exists and has data and tables. I can get…

SQL Server | SQL Server Transact-SQL
asked 2025-06-15T01:20:24.67+00:00
W-Rehman 0 Reputation points
edited a comment 2025-06-15T03:05:07.04+00:00
Viorel 123.6K Reputation points
1 answer

Enable Ledger on Azure SQL Server, will hang the Azure function execution which add around 65K records

I have an Azure function which read data from Excel sheets and update 3 SQL tables, and it clear 2 SQL tables before re-add the rows. On some scenarios, I will add the data as-is, while on another scenario I need to check if a column named ID exists, if…

SQL Server | SQL Server Transact-SQL
asked 2025-06-15T23:41:33.0566667+00:00
john john Pter 1,125 Reputation points
answered 2025-06-16T21:34:34.4166667+00:00
Erland Sommarskog 124.3K Reputation points MVP Volunteer Moderator
0 answers

[SQLServer JDBC Driver][SQLServer]An expression of non-boolean type specified in a context where a condition is expected, near

Hi, I'm getting the following error: [SQLServer JDBC Driver][SQLServer]An expression of non-boolean type specified in a context where a condition is expected, near 'Jul' Here is the code: select 'Actual' SCENARIO, #PROGRESS_TO_HFM.P_YEAR …

SQL Server | SQL Server Transact-SQL
asked 2025-06-20T10:11:18.2766667+00:00
Eldo Mills 0 Reputation points
commented 2025-06-24T12:44:15.83+00:00
Eldo Mills 0 Reputation points
1 answer

Joins vs Functions and Performance

It is axiomatic that joining to another table from your primary table to retrieve data, using primary keys, provides better performance than using a function. At least that's what I know from the last time I cared about it years ago. It's time to care…

SQL Server | SQL Server Transact-SQL
asked 2025-07-03T19:12:57.03+00:00
Don Thompson 0 Reputation points
answered 2025-07-03T19:48:52.9233333+00:00
Erland Sommarskog 124.3K Reputation points MVP Volunteer Moderator