Questions tagged [sql-server]
Microsoft SQL Server is a relational database management system (RDBMS). Use this tag for all Microsoft SQL Server editions including Compact, Express, Azure, Fast-track, APS (formerly PDW) and Azure SQL DW. Do not use this tag for other types of DBMS (MySQL, PostgreSQL, Oracle, etc.). Do not use this tag for issues on software and mobile development, unless it is directly related to the database.
sql-server
336,511 questions
0
votes
1
answer
13
views
zsh: command not found: SqlPackage
I've installed SqlPackage on Mac, for CLI automation/simplication of SQL Server development tasks, however I'm getting error:
zsh: command not found: SqlPackage
1
vote
1
answer
74
views
2
votes
1
answer
72
views
Searching for U+02B9 using LIKE statement match all strings, with or without that character
Consider the following query in SQL Server (I tested with both SQL Server 2019 and 2025):
select val
from (
select val = N'abc'
) x
where val like N'%ʹ%'
Note ...
3
votes
1
answer
105
views
High SQL Server parse and compile time with UDF
I am working on a simple user defined function. It just accepts a varchar(100) parameter, does some string manipulation (nothing more complex than SUBSTRING, CHARINDEX, REPLACE etc. and returns a ...
0
votes
1
answer
83
views
SQL Server versioning table correspondence
Is there a table in MSDN somewhere which shows the SQL Server correspondence values?
SELECT @@VERSION AS 'version', SERVERPROPERTY('ProductVersion')
In this query, ...
Best practices
0
votes
3
replies
67
views
"Serializable" transactions vs guarded atomic UPDATE, concurrency racing conditions
I have been building a concurrent system for a while. In the past I found some articles about "serializable" transactions. I have been using code first EF Core primarily for any database ...
-1
votes
0
answers
61
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 ...
0
votes
2
answers
110
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
60
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, ...
0
votes
0
answers
118
views
Laravel query builder gives unvalid error while copying table
I am trying to run a small SQL query in Laravel without the querybuilder.
...
-3
votes
0
answers
73
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:
...
-4
votes
0
answers
74
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
91
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 =...
-3
votes
1
answer
102
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 ...
Best practices
0
votes
5
replies
52
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 ...
Best practices
0
votes
0
replies
17
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
186
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
99
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 ...
Best practices
0
votes
15
replies
124
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 ...
0
votes
0
answers
137
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 ...
0
votes
0
answers
53
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 ...
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 ...
1
vote
2
answers
150
views
SQL column from different tables to array
I have multiple functions to convert column values into an array
...
0
votes
2
answers
109
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 ...
-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 -
...
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
133
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 ...
0
votes
3
answers
179
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
...
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 ...
0
votes
0
answers
115
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:
...
0
votes
2
answers
71
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:
...
1
vote
1
answer
68
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
<...
3
votes
2
answers
254
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 :
...
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
...
0
votes
0
answers
59
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 (...
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 ...
-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:
...
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
106
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 ...
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 ...
Best practices
1
vote
2
replies
112
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
118
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 ...
Best practices
0
votes
4
replies
165
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,...