336,622 questions
0
votes
0
answers
30
views
Entity configuration for multiple nested value objects in temporal table
I'd like to create a table in my SQL Server. My entity in code contains multiple nested value objects.
My Student table is a temporal table. All properties and subproperties of the class Student ...
0
votes
2
answers
95
views
How do I update row in a table while reading rows with a Java stream (adaptive buffering)?
I get all active items from the database. I check from an external source if they are active or not. And then I set inactive ones as inactive in my database. I do it one by one (as a Java stream) ...
2
votes
0
answers
56
views
How can I safely close the SqlDataReader when retrieving SQL BLOB-data via Stream? [duplicate]
I have the following function which works as an endpoint function in my .NET Web-API. This function reads a BLOB (as varbinary(MAX)) from a SQL database (video, image, audio) and returns is as a ...
-4
votes
0
answers
74
views
Retrieving 50k rows from SQL Server [closed]
I am maintaining a service that needs to retrieve a large amount of data for each request, between 20-40 queries. Another issue is that for some requests only 50 rows per query are returned, for ...
0
votes
1
answer
111
views
Laravel query builder gives unvalid error while copying table
I am trying to run a small SQL query in Laravel without the querybuilder.
$DB = DB::connection('localhost');
$query = 'select * into newtable from oldtable';
$DB->statement($query);
DB::purge('...
-3
votes
0
answers
66
views
sp_columns_ex works on physical Windows but hangs in containerized / KubeVirt Windows environment [closed]
I am facing an issue with a SQL Server system stored procedure behaving differently between environments.
The following query works as expected on a normal physical Windows machine:
EXEC sp_columns_ex ...
-4
votes
0
answers
71
views
How do I add the description property to the table designer view in SSMS 2026? [duplicate]
I’m trying to display the Description property directly in the table designer grid in SQL Server Management Studio (SSMS) 2026. I want column descriptions to appear next to other settings like data ...
0
votes
1
answer
89
views
CASE Expression in JOIN [duplicate]
I am having some trouble with a CASE expression inside a JOIN.
Essentially, what I would like to do, is whenever a FormLookupId = 31 I want to join on any record with the a specific string in the rl....
-3
votes
1
answer
97
views
Group Transaction in To/From columns [closed]
I have this table here as example:
Group
Where
Bill
Amount
A
from
telephone
-300
A
from
internet
-200
A
to
electricity
500
B
from
water
-1000
B
to
cable
500
B
to
gas
500
When you query Group A. The ...
-3
votes
0
answers
63
views
Return Product Loaded in Machine based on Machine and Timestamp [closed]
I have two tables...one (Table A) has product data from 6 different machines...Date/Time, Barcode and Machine Name being the most pertinent for what I am trying to accomplish. The second data set (...
Best practices
0
votes
5
replies
49
views
Conditional lag and retention
How to generate a conditional lag in T-SQL?
If the visit is a D01 visit and VIS_DAT data is present -> retain VIS_DAT
If the visit is a D01/D08 visit, and the VIS_DAT data is missing -> lag ...
Best practices
0
votes
0
replies
16
views
Debezium SQL Server v2: Best practices for handling Schema Namespace fragmentation across multiple DB shards (SpecificRecord issue)
I am looking for advice on how to handle Avro schema namespaces when ingesting data from multiple identical SQL Server databases (sharding scenario) using the Confluent FullyManaged SQL Server ...
0
votes
1
answer
176
views
INSERT unique incremented number from SELECT on the same table by several users without creating duplicates
I have a requirement to generate unique incrementing serial numbers by product type from a VB.NET application using SQL Server Express.
I have created a table and also have a VB form where I am ...
-3
votes
0
answers
98
views
Float value changes when rounded [duplicate]
Found myself with this awkward situation:
As you can see, the value of field "amount" (float) is shown, when not converted/casted, as "10000".
When I cast it to int, it becomes ...
Best practices
1
vote
7
replies
102
views
Why is PostgreSQL COPY significantly slower than SQL Server BULK INSERT?
I’m trying to understand why PostgreSQL COPY is much slower than SQL Server BULK INSERT in my scenario (or every scenario?).
I have 30 .CSV files that are loaded into 6 different tables.
In SQL Server,...
Best practices
0
votes
15
replies
120
views
Any advice on Inner Join query performance
I have a T-SQL query shown here which is taking forever to run.
I am trying to see if there is a better way to write the Inner Join statement. The source table has a millions of rows.
Is there any ...
0
votes
0
answers
136
views
How to get the SQL for an ancient view when none of the usual methods work
I need to get the SQL definition of a view. Problem is, it was created many decades and SQL Server versions ago using whatever GUI was available then, not via a CREATE VIEW statement. Another problem ...
0
votes
0
answers
51
views
How to prevent SSDT/DACPAC publish with DropObjectsNotInSource=True from dropping Azure Functions az_func runtime tables
I’m deploying a SQL Server/Azure SQL database using an SSDT .sqlproj (DACPAC) and SqlPackage.exe (DacFx publish). For local dev we require DropObjectsNotInSource=True so schema drift/renames are ...
Advice
0
votes
5
replies
58
views
Modifying an Access VBA project with VBA
In principle I should be able to write some VBA code, and run it over a VBA project to amend the project.
Scenario: A collection of databases is being moved from one server to another.
There are a lot ...
0
votes
0
answers
37
views
When using isql via ODBC Driver 17 or 18 in Linux, how to login using Windows Account to SQL Server
Using SQL Server authentication and Windows authentication, I can login to SQL Server (via SSMS).
When using isql via ODBC Driver 17 or 18 in Linux, how to login using Windows account to SQL Server?
...
1
vote
2
answers
150
views
SQL column from different tables to array
I have multiple functions to convert column values into an array
CREATE FUNCTION FN_ToArray
(
@separator NVARCHAR(10) = '|'
)
RETURNS NVARCHAR(500)
AS
BEGIN
DECLARE @return VARCHAR(500)
SET ...
0
votes
2
answers
107
views
Incorrect ordering in CTE query
I run the below query against a view in MS Fabric environment (Data Warehouse). Here the compl_officer_id is the same across management_id partition (unfortunately there are no other unique values ...
-1
votes
1
answer
125
views
LINQ to SQL mapping a SQL Server uniqueidentifier to a Guid [closed]
I am trying to access a SQL Server uniqueidentifier using Linq-to-SQL mapping:
Table -
CREATE TABLE [dbo].[Members](
[guid] [uniqueidentifier] NOT NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
...
0
votes
0
answers
54
views
SSIS Package Configuration with OData
I am attempting to use package configuration for an SSIS package that uses an OData Connection manager.
I am using SSIS 2019 and Visual Studio 2022 running on Windows 10.
I am running the following ...
-1
votes
2
answers
129
views
Join two table with column values based on condition being met [closed]
I am trying to flatten out two different tables for a report(view) but I am having a hard time. One table is tbRecord which contains a unique master record id and a sub table tbInspectedPart that ...
0
votes
3
answers
177
views
Trouble with SQL Server query containing DISTINCT, ORDER BY and FOR XML PATH commands [closed]
Here is an extract of table B_TimeEntryMatter.
ProformaNr
ActivDate
Description
451894
17/12/2025
To the provision of a Certificate of Incumbency by the Secretary;
451894
18/12/2025
To time spent in ...
0
votes
1
answer
107
views
sqlcmd command not found in SQL Server 2022 Docker container
I'm running SQL Server 2022 in Docker:
bash
docker run -d -p 1433:1433 --name sqlserver -e "SA_PASSWORD=youdontneedtoknow" -e "ACCEPT_EULA=Y" mcr.microsoft.com/mssql/server:2022-...
0
votes
2
answers
170
views
SQL join using BETWEEN => GREATER THAN Val1 and LESS THAN or EQUAL TO Val2
I need to join 2 tables based on a column named TRANS_ID. The problem is, one table has all available TRANS_IDs and the other table only has SOME of the available TRANS_IDs.
For instance, take this ...
9
votes
1
answer
319
views
"Aggregate functions are not allowed in recursive common table expression" - but actually, they are?
I have table of structure data in SQL Server. I want to travese the tree and find all nodes with a recursive query.
Additionally, the structure data is versioned. I want to always use the latest ...
Advice
0
votes
6
replies
38
views
How would I add a catalog to a SQL Server in SSMS
I have seen a number of articles on this but none seem to answer the question.
How would I add a catalog to a linked server in SSMS?
1
vote
1
answer
77
views
Invalid user defined type, reason: no UDT attribute
For some reason I am unable to retrieve an SQL CLR user-defined data type using SqlDataReader.
The type seems to be formatted correctly and I can see the type in the data reader in debug, however as ...
0
votes
0
answers
113
views
Pivoting table doesn't return the expected results
I am trying to use pivot, but it's not working the way I expect.
The temptable I want to use input is #GenericTeam:
Versionnumber
Valid_from
Team_name
Attributenumber
Attribute_displayname
...
0
votes
2
answers
70
views
Parsing an XML column in T-SQL with a colon in the XML Structure [duplicate]
I have a column of XML data in SQL Server that I'm trying to parse into columns. The start of the XML data looks something like:
<DataSet xmlns="google.com">
<diffgr:diffgram ...
1
vote
1
answer
67
views
Creating a folder in the SSISDB catalogue
After migrating my database to another server, I can't create folders in the SSISDB catalogue; I get this error:
Operation 'Create' on object 'CatalogFolder[@Name='test']' failed during execution. (...
0
votes
2
answers
151
views
Single quote thousand separator
I need to show numbers with a single quote thousand separator in a SQL query, for example:
1'000.00
I tried with something like
FORMAT(ISNULL(value, 0), N'N2')
or
FORMAT(ISNULL(value, 0), '###,###,##...
3
votes
2
answers
252
views
Exception in C# code when trying to call a stored procedure with encrypted param
I have table with an encrypted column UserName:
I also have a stored procedure (in SQL Server) defined as below :
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[...
Best practices
1
vote
11
replies
120
views
Avoid using OUTER APPLY in Query
Employee table:
Id
Name
1
John
2
Peter
Attendance table:
Id
EmployeeId
DateTime
1
1
2026-01-10 09:00:00
2
1
2026-01-10 14:00:00
3
1
2026-01-10 15:00:00
This is my SQL query:
SELECT
E.Name, A....
0
votes
0
answers
58
views
LIKE with NVARCHAR parameter returns incorrect results [duplicate]
I am getting incorrect results to a LIKE query when the like-string is defined as a NVARCHAR type parameter.
The problem happens when including either brackets (span of characters) or underscore (any ...
0
votes
2
answers
205
views
Setting OrderNumber of rows in a table
I have a TimeZones table that provides a list of all the time zones in the world with names, offset info, etc. I also have a CountryId column in my table which tells me which country time zones are in ...
-1
votes
1
answer
136
views
SQL query for retrieving XML nodes parent child nodes [closed]
I have an XML and now I want to retrieve the XML nodes and its values in SQL Server and add it into a SQL Server table.
This is my XML:
<ADN>
<gift>
<giftdetail>
<source&...
0
votes
1
answer
75
views
How can I query a unbuffered query in SQL Server with Hibernate?
I am not sure if Hibernate has a support for unbuffered queries but if it has how can I run an unbuffered query on SQL Server with Hibernate?
0
votes
0
answers
32
views
Azure DevOps upgrade failed over SQL Server cert [migrated]
Trying to upgrade on prem Azure DevOps 2022.2 to 2026. I've installed the bits and run the configuration wizard. The upgrade failed over inability to connect to the database, because the SQL Server ...
0
votes
0
answers
105
views
Extended Event session not capturing
I created the this event session to capture queries that hit our server (I have altered predicates just to try and get something working) and nothing seems to be captured.
I have checked sys....
0
votes
2
answers
134
views
DevExtreme DataSourceLoader SQL Error "Conversion failed when converting date and/or time from character string" with EF Core
I am building an ASP.NET Core Web API with an Angular frontend using the DevExtreme DataGrid. I encounter a SqlException when trying to filter my grid by a date column:
Microsoft.Data.SqlClient....
-4
votes
0
answers
66
views
How to shrink database file best way? [duplicate]
I have a 3+ TB database on SQL Server 2019 which has more than 50% free space. I know database or data file shrink is not a good practice so please not go there, I tried with 100 mb in a loop which is ...
Best practices
1
vote
2
replies
111
views
T-SQL ETL update evaluation recommendation: What is the most elegant & performative way to evaluate a source value to update a target value?
What recommendations might be offered for the most elegant and performative way with T-SQL to evaluate whether a source value should update a target value, as part of an ETL update process in which ...
Best practices
0
votes
3
replies
116
views
Do SQL databases apply WHERE filters before joins?
from a in xx
join b in yy on a.someprop equals b.someprop
join c in zz on a.someprop1 equals c.someprop
where a.someprop2.Contains(strval)
I’m trying to understand how SQL query execution works ...
Best practices
0
votes
4
replies
163
views
How to ensure an inserted row survives a rollback?
In SQL Server, I have a stored procedure that returns some sensitive data to the client, and logs that fact into a log table. The stored procedure is executed in a transaction controlled by the client,...
0
votes
1
answer
74
views
Gemini CLI and MCP of SQL Server extension
From reading:
https://docs.cloud.google.com/sql/docs/sqlserver/pre-built-tools-with-mcp-toolbox#mcp-configure-your-mcp-client-geminicli-sqlserver
I get this error:
✕ Error during discovery for MCP ...
0
votes
1
answer
102
views
SqlBulkCopy is failing to save records with an error "The given ColumnMapping does not match up with any column in the source or destination."
I have table defined like this:
CREATE TABLE [staging].[tbPositionAssetIdentifier]
(
[StageID] [int] IDENTITY(1,1) NOT NULL,
[AssetId] [nvarchar](50) NULL,
[SecurityDescription] [nvarchar]...