Questions tagged [sql-server-2019]

Use this tag for questions specific to the 2019 version of Microsoft's SQL Server.

New Features Of SQL Server 2019

  1. Intelligent Query Processing Enhancements enter image description here
  2. Accelerated Database Recovery (ADR) enter image description here
  3. AlwaysEncrypted With Secure Enclaves enter image description here
  4. Memory-Optimized Tempdb Metadata
  5. Query Store Custom Capture Policies
  6. Verbose Truncation Warnings
  7. Resumable Index Build
  8. Data Virtualization With Polybase enter image description here
  9. Last Actual Execution Plan DMF
  10. Multiple Internal Performance Improvements

Reference : What's new in SQL Server 2019 (15.x)

977 questions
-2
votes
2 answers

How to use Trim in select queries for data in SQL tables

I have a table which stores data for AD users in one of columns like abc\sam, abc\bill, xyz\Ramos etc.. (domain\username) I am trying to use select query to trim anything after\ and just give me domain with their location. That is, after trimming…
Newbie-DBA
  • 107
  • 5
-2
votes
1 answer

SQL Server - Move duplicate records into a different table

Employee_table Id FirstName LastName Division 1 John Smith A 2 Emily Jones B 3 John Smith B 4 John Snow A 5 John Smith C I want to move all duplicate names from Employee_table to a table named Dupes. Dupes has the all the same…
bigShaq
  • 69
  • 11
-2
votes
2 answers

Sort an array of strings in SQL

I have a column of strings in SQL Server 2019 that I want to sort Select * from ID [7235, 6784] [3235, 2334] [9245, 2784] [6235, 1284] Trying to get the result below: [6784, 7235] [2334, 3235] [2784, 9245] [1284, 6235]
Poola Tony
  • 23
  • 2
-2
votes
2 answers

SQL Server 2019 : Subquery Join won't execute

I have to design a report which will be a list of a bunch of overlapping data from the same table. I have to start with the Project table because for the report @ProjectId is the only thing you get as an anchor. In the RessourceBookings table are…
IrishWolf
  • 19
  • 5
-2
votes
1 answer

How to dynamically write OR clause in Contains query?

Is there a way to generate the second part of this SQL query (OR clauses) from a string split? WHERE CONTAINS(t.something, '"bla*" OR "foo*" OR "batz*"') String split values come from : DECLARE @String_With_Commas varchar(max); SET…
-2
votes
1 answer

Unexpected order running OR operator on SQL Server 2019

I'm having a problem when migrating from SQL Server 2008 R2 to SQL Server 2019. My code DECLARE @str NVARCHAR(50) = 'all', @int TINYINT = 1 DECLARE @tmp TABLE (val nvarchar(MAX)) INSERT INTO @tmp VALUES('123') INSERT INTO @tmp…
Nguyễn Văn Phong
  • 13,506
  • 17
  • 39
  • 56
-2
votes
1 answer

filtered INDEX on Sql Server table causes errors during Insert

I have a table in SQL Server 2019 which defined like this: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON GO SET ANSI_PADDING OFF GO CREATE TABLE [dbo].[productionLog2]( [id] [int] IDENTITY(1,1) NOT NULL, [itemID] [binary](10) NOT NULL, …
VSB
  • 9,825
  • 16
  • 72
  • 145
-2
votes
1 answer

Dynamic pivot for any number of columns and rows

I have the sample device table and data below. I am trying to find a way to transpose or pivot the rows into columns, while adding more devices (rows) and more attributes (columns) over time, while keeping the query intact but I couldn't find a good…
Tony_Henrich
  • 42,411
  • 75
  • 239
  • 374
-2
votes
1 answer

I want to write a function in Microsoft SQL Server to validate any UK Phone numbers and flag 1 if valid and flag 0 if invalid

This is my code: FUNCTION [dbo].[Vmobile](@mobileno VARCHAR(50)) --Returns true if the string is a valid mobile no. RETURNS bit AS BEGIN DECLARE @valid bit IF @mobileno IS NOT NULL SET @valid = 0 IF…
john
  • 119
  • 1
  • 8
-2
votes
1 answer

Loaded multiple files in table and now want to find Min and Max value is coming from which file

I have loaded multiple files in SQL Server. Let's Say table structure Now select COL_A, min(COL_C),max(COL_C) from tbl group by COL_A I want to write SQL query to find which file has that Min(COL_C) and Max(COL_C) value. As you can see I am…
-2
votes
3 answers

Build a report with SQL with combining columns and rows?

Here is my table: Table Purchase…
KojTug
  • 351
  • 1
  • 8
-2
votes
1 answer

how to limit selection with select

I tried using limit order to get a result like student_id | name | major 1 | kate | bio 2 | david | chem 3 | jake | math instead of student_id | name | major 1 | kate | bio 2 | david | chem 3…
-2
votes
1 answer

Create a loop function which passes in the foreign key

I am working on an assignment where I have to create a database using SQL Server 2019. I am wondering how to create a function which uses the existing PK of one table and puts it into the FK of the linked table. I can't upload a picture of it. But…
-3
votes
1 answer

Why sp_executesql is giving syntax warning

Question: On the first line, why the following query giving the syntax warning shown in the image below. How can we fix the warning? DECLARE @USstate nvarchar(15) = N'OHIO' DECLARE @sql1 nvarchar(500) SET @sql1 = CONCAT('SELECT * FROM Customer WHERE…
nam
  • 21,967
  • 37
  • 158
  • 332
-3
votes
1 answer

SQL Server: Nested cursor missing first row in the inner cursor

I went through the Microsoft documentation and implemented the nested cursor,but somehow it is missing the first row of the inner cursor. Below is the query to review. DECLARE @client_id VARCHAR(50); DECLARE @reportID INT; DECLARE @report_name…
Niranjan Singh
  • 18,017
  • 2
  • 42
  • 75
1 2 3
64
65