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…
COALESCE and CONCAT Address Line 1 and Address Line 2 separated by a comma
We are trying to COALESCE and CONCAT Address Line 1 and Address Line 2 separated by a comma "," from potentially two data sources. So like...123 Main St., Apt. 101 The first part is easy enough... CONCAT ( COALESCE ( LTRIM (RTRIM…
How to get the current row value based on previous row value in sql server- ex first row has value, calculate the second row value using first row and some conditions and 3rd using 2nd row and same conditions
when basin <> prebasin, numberinbasinnew=numberinbasin. when basin=prebasin use the numberinbasinnew from the first row (basin<>prebasin) and calculate the second row value for numberinbasinnew based on below conditions -- CASE …
Sql server how to change column type from int to date
Sql server how to change column type from int to date
"Data Flow Task:Error: SSIS Error Code DTS_E_CANNOTACQUIRECONNECTIONFROMCONNECTIONMANAGER. The AcquireConnection method call to the connection manager ""Oracle_XXXX"" failed with error code 0xC0014009. There may be error messages posted before this
SSIS using task factory component and brings data from Oracle to SQL Server. SSIS package execute successfully on dev SQL Server environment and it returns errors on production. It runs scheduled as a job. Both servers are 2019 and identical. Here is the…
remove duplicates
hi all, I have this kind of duplicates: ID Line Amount === === ====== 100 1 1000 100 2 100 100 1 100 100 2 1000 101 1 2000 101 2 500 101 3 …
Account ledger query with debit and credit
Hi All respected community member, i am trying to develop ledger query from long time still i could not get ,please do review and help me out , if you have any suggestion for restructure #tbl_Transection_test table ,please let me know or guide me…
Split one column into multiple column
Dear my friends, I have a question about how to split one column into multiple column ? I've try the code but it doesn't work Does anyone could help me ? Thank You for your help Best Regards, Steve Henry
SQL Stored Procedure BULK INSERT wont execute when called from Kubernetes Cluster
Hi There, I have a Python Program that calls a Stored Procedure on a SQL Managed Instance in Azure. This stored procedure, deletes data from a staging table and carries out a BULK INSERT of Data from CSV files that are stored in a Storage Account…
Correct SQL query to not repit articles
Hello, good afternoon, I have the following query in SQL and it is returning duplicate items. I managed to decipher that the items that are duplicated in the "On Orders" column in one row appear with one quantity and in the next row (Same item,…
CURSOR for column in WHERE that gives dynamic columns in SELECT
Hello, I need help to make my query more simple Depends how many rows for column Code (now I have 53 rows) then it will be 53 sub selects and 53 more columns. How to make it simple to add variable in select and in sub select instead of writing 53 times…
How to get the non null row before the row with null value
Hi I want to see the non null row before the row with NULL value in the result set. I have data in below in format I want to see ID 2 row in the result set like below Help with this would be appreciated.
Runing SSAS Tabular Processing Script (TMSL) from SSAS Database Engine
Hello Experts, In continuation of my previous question https://learn.microsoft.com/en-us/answers/questions/2076521/processing-monthly-partition-from-sql-job-using-st?source=docs We have SSAS Tabular model database and SSAS Database engine. When trying to…
How to get a date of day in current week
Hi, I have table that stores configurations like In my sql code, I need to take currentDateTime and get current week date for Execution Day which is Wednesday. So, for this week, it will be 10-02-2024. Get following week wednesday date. Here it…
better query for select results based on date.
What is the best way to write this code to get the date results? I have the time throughout the day in the datetime field. SELECT * FROM Reconciliation.Documents D Inner Join Reconciliation.DocumentsTransaction T ON D.DocumentPKey = T.DocumentPKey WHERE…
Like to review records incorrectly entered in the database
We have a database where we enter a record with a number with an alphanumeric suffix. But the software entered it incorrectly due to an algorithm issue which we are trying to fix now but past transactions need to be fixed in the database. If I know the…
date function in Sql
I have a timestamp where I want to query only based on the date and exclude time.
Way to optimize query where no union needed
I had to use union on two very similar queries where one is just a copy of the other but the having clause is equal with an additional condition in the where clause. Is there a way to clean up the code? DECLARE @PO_DATE_FROM date = '2024-09-08',…
Queries in the same window for multiple databases, servers, and tables
I was wondering in SSMS in the query window could I write multiple queries that use different servers, databases, and tables? A compounded question and answer I am expecting for this.
SET FMTONLY ON/OFF is deprecated according to the docs and should be replaced by sp_describe_first_result_set. But sp_describe_first_result_set returns 'incorrect syntax' message on correct queries. How to correctly migrate?
Using this simple table structure: CREATE TABLE Persoon_ ( ID INT, Adres NVARCHAR(50) ) CREATE TABLE Factuur_ ( ID INT, Debiteur INT, Persoon INT, Bedrijf INT, Derde INT ) CREATE TABLE Bedrijf_ ( ID INT, FactuurAdres NVARCHAR(50), …