SQL Server 2022 is a release name of the Microsoft SQL Server 16.0 released on November 16, 2022. Use this tag only for questions about SQL Server 2022 specific questions. For generic questions about SQL, T-SQL, or Microsoft SQL Server, please use tags [sql], [tsql], and [sql-server] instead.
Questions tagged [sql-server-2022]
60 questions
0
votes
1 answer
Replace a Data Bar With an Image Based on Data Value
I have a requirement to produce a Scorecard in SSRS. The Scorecard has a column containing a Data Bar where the bar length indicates the severity of the issue on the scorecard line. When the severity of the issue is ZERO, the Data Bar should be…

cltdiver
- 83
- 1
- 1
- 7
0
votes
1 answer
Strange behavior with a scalar function that uses a table value function
In a SQL Server 2022 database (compatibility level 160), I get this error when executing a scalar function:
Msg 245, Level 16, State 1, Line 22
Conversion failed when converting the varchar value 'PA' to data type int.
Code:
ALTER FUNCTION…

Misael
- 1
- 1
0
votes
1 answer
Why does R crash when retreiving data from RODBC?
I'm running R 4.3.1 on Windows 10 using RGui. If I connect to my database:
library(RODBC)
connstr = sprintf('driver={ODBC Driver 17 for SQL Server};server=%s;database=%s;uid=%s;pwd=%s',
/* my parameters */)
dbhandle <-…

MikeB
- 1,452
- 14
- 28
0
votes
1 answer
Index SELECT MAX with WHERE
I know that this question was asked many times, but I could not find an explicit answer when there is a WHERE clause as well, and this is very important for me since I will have table with Millions of records.
If I have:
SELECT MAX…

Vlad
- 15
- 3
0
votes
1 answer
Computed Column on Split Value?
Using SQL Server 2022, attempt to create a computed column for indexing/queries on the 3rd part of a string separated by slashes (it's a URI).
ALTER TABLE MyTable
ADD SpotName AS (CAST((SELECT Value FROM STRING_SPLIT(FullUri, '/', 7)) AS…

Snowy
- 5,942
- 19
- 65
- 119
0
votes
2 answers
Split Variable Pairs into Columns?
Using SQL Server 2022, I'm trying to figure out how to use STRING_SPLIT in a set-based way to convert a table column where all rows have a variable number of key/value pairs into a table without duplicates, similar to T-SQL split string but not…

Snowy
- 5,942
- 19
- 65
- 119
0
votes
1 answer
How to create a dynamic order by query with with multiple fields
I am trying to create a sproc with multiple order by fields. The order by field and direction is passed through the sproc as arguments.
CREATE PROCEDURE GetFilteredLogs
@FromDate datetime2,
@ToDate datetime2,
@SearchText …

Joshua
- 65
- 5
0
votes
0 answers
SQL Server 2022 - error when in function only - The ORDER BY position number 2 is out of range of the number of items in the select list
In SQL 2016 I had some functions that contained selects with order by [position] instead of [column name].
They stopped working in 2022. Now they return the error The ORDER BY position number 2 is out of range of the number of items in the select…

Cristina
- 1
0
votes
0 answers
What is the best way to check if user has permission from another table in SQL Server?
Please consider the following SQL:
CREATE TABLE [dbo].[Permission]
(
[Id] UNIQUEIDENTIFIER NOT NULL,
[UserId] UNIQUEIDENTIFIER NOT NULL,
[ProductId] UNIQUEIDENTIFIER NOT NULL,
[OptionA] BIT NOT NULL DEFAULT 0,
[OptionB] BIT NOT…

Bagzli
- 6,254
- 17
- 80
- 163
0
votes
1 answer
How to get only 1 or 2 records on many to many table relation based on default column and passed language id
Please consider the following tables and data that is inserted:
CREATE TABLE [dbo].[Language]
(
[Id] UNIQUEIDENTIFIER NOT NULL,
[Name] NVARCHAR(256) NOT NULL,
[Culture] NVARCHAR(10) UNIQUE NOT NULL,
[DateCreated] DATETIME NOT NULL…

Bagzli
- 6,254
- 17
- 80
- 163
0
votes
1 answer
C# / SQL: How to get easy/automatic mapping of a Database table to Class?
I don't have much experience of C# & Database. My chef engineer has built tables in a database.
In C# code he has built a class for each table with all the information that is already in the database table (see code extract). I am wondering if this…

DataSalad
- 11
- 2
0
votes
0 answers
Is it possible to have 2 analysis services linked to one Database engine? How do I install the second one?
I am using SSMS 2022, and I have installed Database engine (developer server) for it. After that, using SQL SERVER Installation Center ( SETUP.EXE file in developer folder) I chose to add features to an existing instance of SQL Server 2022, and…

Natalija R.
- 1
- 3
0
votes
0 answers
SSAS Tabular Model Upgrade
I have an old SSAS Tabular model (Compatibility Level = 1103) in a Visual Studio SSAS Project
Recently the client created a new SQL Server running SQL 2022. I want to upgrade and deploy the current Tabular Model to be able to run on the new…

LordRofticus
- 181
- 1
- 2
- 13
0
votes
1 answer
How to use MERGE to update only changed columns?
I have this query which syncs the target table with the source table. Missing rows in the target need to be inserted, changed rows (only number and name) need to be updated, and missing rows in the source need to be deleted from the target…

Ivan Debono
- 457
- 3
- 14
0
votes
2 answers
How to determine which server you are on when running in a Cluster
Our company now has a Sql Cluster consisting of two different Sql Servers. This works fine.
The difficulty, however, is knowing which server you are on. For the purpose of making sure that an SP is on Prod (and not on Test) we often do a check on…

Greg Gum
- 33,478
- 39
- 162
- 233