184 questions
Score of 0
1 answer
92 views
ConnectionError: Failed to connect to localhost/SQLEXPRESS01:1433
I am trying to build a web API using Express + Typescript using this Github repo as a starting point. I am using the mssql package with the default tedious driver.
This is my config:
server: '...
Score of 0
1 answer
150 views
Get an history of changes of many tables
I have 3 system-versioned temporal tables, let's call them FOO BAR and BAZ.
They are linked like this:
FOO -> 1-N -> BAR -> 1-N -> BAZ
I want to retrieve the full change history for a ...
Score of 0
0 answers
108 views
SQL Server Polybase importing parquet: Operand type clash: bigint is incompatible with datetime
We have a parquet file on S3 and are importing it into SQL Server 2022.
The issue is that mydatetimefield is a timestamp dtype (internally stored as bigint) in parquet file and the dtype on import ...
Score of 2
2 answers
102 views
Creating EzApi for SQL Server 2022
I used EzApi to generate SSIS (SQL Server Integration Services) packages programmatically in C#. Back then, I relied on the original Microsoft EzApi project from CodePlex, which has been discontinued ...
Score of 0
1 answer
223 views
Why does SQL Server 2022 treat formatting time different than datetime?
I'm working on a project for work, where initially I was going to store a time in a datetimeoffset field in a table. I only care about the time and not the date, so I was going to use a placeholder ...
Score of 1
2 answers
163 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 ...
Score of 0
0 answers
155 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....
Score of 5
3 answers
134 views
How to pick second value for same ID with other conditions
I have a Region table where MapID is the primary key. Each MapID can have EmployeeID or Zip5.
For any MapID, EmployeeID takes the precedence over Zip5 i.e. for any MapID, if there is an EmployeeID, ...
Score of 0
3 answers
106 views
How to group the data to avoid multiple rows
I have an employee Manager table where you can see for every deptID, there are multiple rows.
A few rows have null employeename and a few rows have null managername for same DeptID. i would like to ...
Score of 0
1 answer
152 views
Aggregate function for bit-wise OR [duplicate]
In SQL Server 2022, is there an aggregate function for doing a bit-wise OR against a particular column?
-- Example table, data and output to show the different flags
DECLARE @TEST TABLE (FLAGS TINYINT)...
Score of 0
1 answer
147 views
SQL Query to select a string after an extension [duplicate]
Values:
1.zzz- Pipo
test.zzz-Done
blabla2.zzz-zip3
My question is, how can I get everything after .zzz- so the select statement from the value above will return:
Pipo
Done
zip3
Score of 1
3 answers
203 views
XML Set the Element Name from Attribute Value
I have a table of answers from a submission form that I need to convert to an XML file and upload to a website. Each row is one answer from one submissions and the answers need to be stored as the ...
Score of 0
2 answers
225 views
For ERROR_NUMBER 515, how to get the column name from ERROR_MESSAGE
In many SQL error messages, SQL Server does not mention column name. But in messages such as the one shown below, the error message does include the column name.
Question: How can we extract the ...
Score of 5
4 answers
190 views
Combine rows to remove nulls or swap row values if not null
Input table:
ID Account Contact
-----------------------
ID1 A11 C11
ID1 A12 NULL
ID2 A21 NULL
ID2 A22 C22
ID3 A31 C31
ID3 A32 C32
Output needs to be like this
ID Account Contact
-------------------...
Score of -1
1 answer
129 views
Counting unique records across two tables [closed]
I have two tables
The first table is my INVOICEHEADER which contains one record per invoice, but multiple records per order. InvoiceNumber is the unique key on this table (there is no table for ...