336,214 questions
Score of 1
0 answers
49 views
Why does node-mssql connect to the primary replica when using ApplicationIntent=ReadOnly?
I have a SQL Server Always On Availability Group with one primary replica and one readable secondary replica.
I want my Node.js application to send read-only connections to the secondary replica.
I am ...
Score of -6
0 answers
138 views
How can I get a runtime SQL error Incorrect syntax near ')'. without using exec? [closed]
I get this exception head:
SqlException: Incorrect syntax near ')'.
at Microsoft.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
...
Score of -4
0 answers
149 views
Insert of XML record into SQL table through stored procedure call [closed]
I have a stored procedure that accepts an XML input parameter. Inside the procedure, I parse the XML data and attempt to insert the extracted values into a SQL Server table.
However, the insert ...
Score of -2
1 answer
118 views
Faster way of getting unique comma separated list within SQL query [closed]
After adding in additional variant tables (and increase in data), some SQL views have become unacceptably slow.
I think the problem is this 'clever' trick I'm using to pull what could otherwise be ...
Score of 1
5 answers
148 views
Return multiple text and associated number from string
Trying to return all instances of a word and number from a string, I've put this together but only grabs the first occurrence as opposed to looping through the string to return all instances of text+...
Score of 0
1 answer
151 views
Not null column expects input value in stored procedure even though it is set to be an output parameter [closed]
This code worked fine several weeks ago, but suddenly started in with errors.
I have a situation where I have a column in a SQL Server database that is of the not null type. In my C# code, I call a ...
Score of 0
0 answers
253 views
Why is Dapper failing to substitute a parameter in a SQL statement
I have the following method in my code to query a table with an encrypted column in SQL Server.
public async Task<ConnectionDetails?> LoadConnectionDetailsBy(string systemId, CancellationToken ...
Score of 0
0 answers
10 views
SQL Server 2022 PSPO does not create multiple query plans for a highly skewed parameter [migrated]
I am trying to demonstrate Parameter Sensitive Plan Optimization (PSPO) in SQL Server 2022 using a highly skewed dataset.
My Orders table contains about 10 million rows:
OrderStatus = 1 → ~9,999,000 ...
Score of 0
0 answers
10 views
Why optimizer does not perform merge join in this particular query? [migrated]
I'm learning how SQL Server chooses join strategies and I hit a result I can't explain.
I have a transactions table (~10M rows) and a card_banlist table (~1M rows). I want every transaction that ...
Score of -1
2 answers
203 views
Why does the first database write take significantly longer than subsequent writes?
My application has some method called Write that writes data to a SQL Server database, The method first calls custom AddRange method which adds data to the context if it's not already tracked by the ...
Score of -6
2 answers
198 views
Prefix of string up to first numeric value
I have a formula in Excel that I'm looking to recreate in SQL Server (T-SQL). Basically, I need to return the prefix of the string up to the first numeric value as one data point and everything from ...
Score of 3
2 answers
194 views
Is splitting rarely-queried wide columns into a separate table a sound way to speed up scans on unindexed columns?
I know larger rows scan slower in the trivial sense (more bytes = more I/O). My question is specifically about one design choice: whether splitting rarely-needed wide columns into a separate table is ...
Score of -1
0 answers
149 views
Upgrading SSIS 2025 to .NET Framework 4.8 keeps reverting to 4.7
I am trying to upgrade my SSIS 2025 projects to use .NET Framework 4.8. I'm currently using .NET 4.7 successfully.
I have Visual Studio 2022 64-bit v17.14.7. My target server version is SQL Server ...
Score of 0
3 answers
149 views
When dropping & recreating a table with the same name, do associated objects (stored procedures, views, triggers) handle that?
I need to drop and recreate a table (with the same name) in an existing database.
Will the various objects in the database that reference that table work fine after the table drop/recreate? (eg., ...
Score of 2
2 answers
246 views
How can I exclude holidays using my custom holiday table in my SQL code that excludes weekends
I have completed my SQL code to exclude weekends, but how can I incorporate my dbo.Holidays table into my code to exclude those dates from being added to the 3 days?
In below example, for ContactID = ...