Scalability LEFT JOIN vs MERGE
Hi there, I'm UPSERTING AND handling 70 + millions of rows of UPSERT. I'm the only developer on the DB. GP_Gen5_6 LEFT JOIN DURING UNIT TEST OF ALL RECORDS 12 mins SCALED UP OVERNIGHT PROCESS GP_Gen5_20 History of existing MERGE process same operation…
Select with Conditional COUNT
Hello everyone and thanks for the help in advance. In a prevous post https://learn.microsoft.com/en-us/answers/questions/2148980/counting-occurrences-in-a-table, Erland Sommarskog built a query for me that counted the occurrences of vaccines by patient.…
Invalid object name 'STRING_SPLIT' in SQL Server 2019
Hi Support, Our SQL server version is 2019 and check the compatibility level is 150, but it still have error "Invalid object name 'STRING_SPLIT' ". We also tried the case sensitive according to this link, both of them have the same error. …
How to figure out the total number of doses within a time span given to a client as dose are being added and stopped.?
If the cadence values are different, even if the dates overlap the records must be separate. If an order for the same dose and cadence value (including nulls) starts on the same day or the next day (+or-1 day) the record should continue. outlook of…
Run SQL Statements Parallel within a SP
Hi there, Is there a way to run SQL Statements in parallel within the same SP? Thanks for your time. CREATE PROCEDURE CustomerPARALLEL AS BEGIN EXEC DBO.CUST1 - TAKES 20 MINS (INDEPENDENT) EXEC DBO.CUST2 - (TAKES 20 MINS (NO DEPENDENCY)) HOW TO…
Microsoft SQL Server Studio - Dark Mode
Is there any official method to use Microsoft SQL Server Management Studio Studio with Dark Mode?
How to get a CSV file from a T-SQL in SQL Agent
I am using SQL agent to schedule a task. This task is the execution of a script that performs a query to several databases and concatenates the output. I have managed to obtain a file but not a CSV file, that is, I cannot obtain a file separating the…
SQL gaps and island issue
Greetings!!! We're working on migrating data from a legacy application and have a requirement to get all the consecutive SESSION START_DATE & END_DATE. For the SESSION_ID - 8642, SESSION_TYPE - 3256, based on the requirement using sql server query…
A Simple SQL Query
I have the following table:- I want Col 1 and Col 2 where Col2 =1 and the corresponding all the values of Col 1 where Col 1 =2. But this is an example. I can find 1st part (i.e,, Select Col1, Col 2 from Table1 where Col 2 =1). But my problem is how do…
Find ALL UNUSED columns on SQL DB Tables
Hi there, Is there a way in AZURE SQL Server to find all columns of a table which are NOT used by ANY SPs or Views. I have 65000+ columns in DB based on information schema columns. I do see 200+ SPs of which not all columns are used. Some have select *…
How to write a Simple TSQL
I have the following table:- I have two requirements. the 1st one is, I need ColA and ColB when ColB is 1. So the query would be:- Select ColA, ColB from Table1 where ColB =1. The Output of the 1st requirement is:- Now the 2nd requirement is, as the…
UPSERT - CAPTURE UPDATED ROWS INTO ANOTHER AUDIT TABLE
Hi there, I'm trying to do soft delete on a target table which are not in source. Basically if the ID is not in source but ID is in target, update that RecordStatusKey of that specific target ID. I would like to capture the records updated in merge. Is…
Counting Occurrences in a Table
Hello everyone and thanks for the help in advance. I need to develop a MVC application that reads a SQL database of patients who have received vaccines. The table looks like: [ID] [int] IDENTITY(1,1) NOT NULL, [MRNumber] [varchar](50)…
@@ROWCOUNT issue
Hi there, I had the below code and it worked fine in counting the records inserted and logging insert counts. CREATE PROCEDURE ProcessCustomer AS BEGIN DECLARE @RowsInserted INT; -- Insert into the final table and capture row count …
Strip non numeric characters from string
Hi there, Happy New Year! I'm creating a new table (billions of records). I need to strip non numeric values from a column. Input '.I82807- R%' Output 82807 i created a function based on online however ITS SLOOOOOWWWWWW.... Wanted to check if…
How do I update DBContext after adding new table to SQL database?
We added a new table to our SQL Server database called Occupation. From the ASP.NET Web Form project, I can not seem to access it. Imports System.Data.Entity Public Class CCDBContext Inherits DbContext Public Sub New() …
Avoid unnecessary updates on MERGE UPSERT
Hi there, You all might have used UPSERT operation using MERGE. Currently the update section updates all rows once the key is matched. Is there a way to update only rows which have column value changed and not update all rows to avoid unnecessary updates…
Identify the users with minimum votes and allocate new votes to that user in Synapse SQL
Hello Experts I came up with one problem where I am looking for a solution as I have two tables: Table1: Users |UserID | TotalTasks| | A3 | 12 | | A4 | 14 | | A5 | 11 | Table2: Tasks | TaskID | NewTask| | 1 …
stored proc
Hello, I have a stored procedure which does the following: 1- filter tables and place data into #table1 2- filter tables and place data into #table2 ... Then at the end of the stored proc, select columns by joining these #tables. I have several stored…
Alternative approaches for Recursive CTE in SQL server. The data is 1 million records. need to calculate the current value based on previous value and iterate through Million records. Please suggest a methods which performs better than Recursive CTE
here is the query for your reference. Thanks! Alternative approaches for Recursive CTE in SQL server. The data is 1 million records. need to calculate the current value based on previous value and iterate through Million records. Please suggest a…