Quantcast
Channel: Questions in topic: "cte"
Browsing all 75 articles
Browse latest View live

CTE to delete large amounts of data

Hi, I have an archiving exercise to undertake and one of my concerns is the resources it will take to do the deletes from the live table. I have been investigating using cte and dumping a list of id's...

View Article



Updating a value from initial version to all its higher version with out...

Hello, I have a table Document where the versioning of each document is managed in a linked list format, CREATE TABLE Document ( DocumentID NUMERIC(16,0), OriginatingID NUMERIC (16,0), PrevVesrionID...

View Article

execution plan on cte

As CTE is like derived table. Can we rely on execution plan created on CTE ? After parser gives the parser tree, will the optimizer calculates the execution process correctly ? As CTE is not an object...

View Article

Common Table Expression

I am using @Oleg's fnsplitstring function, and I am looking for a way to insert the resultset into a table on a different database

View Article

Sql Server Recursive Stored Procedure

Want to create a stored procedure with CTE and want to know what the performance hit will be: DECLARE @Directory Table( DirId INT, ParentId INT ) DECLARE @Files Table( FileId INT, DirId INT ) INSERT...

View Article


Using CTE and temp a temp table

1. CTE is used to create the Union between table-A (risk data) & table-B (audit data) 2. The a #temp table is updated with set...case statements from both table-A and B. 3. Then ;with CTE AS... sum...

View Article

Linked report using CTE

My report produces summary data using CTE's and updates a temp table. Now I need to add drill down capabilities with a linked report. The problem is it currently only has summary but I need detail for...

View Article

CTE Data type conversion error

Could someone please help with this CTE? I keep getting this error and warning. Conversion failed when converting the varchar value 'None' to data type int. Warning: Null value is eliminated by an...

View Article


Returning the wrong date

Any Idea why this CTE is not returning the two coreect months I want which are 201005 and 201105? It keeps returning 2030 and 2031 WITH Data AS ( SELECT SUM (h.Arr_Value) as Total, s.ZACCOUNT,...

View Article


Complex-CTE

I have a problem with the following query: WITH CTE_1 (stu_id ,meet_doc_id ,doc_name ,stu_name ,dob ,done ,date_meet_doc) AS (SELECT stu_id ,meet_doc_id ,doc_name ,stu_name ,dob ,CASE WHEN...

View Article

CTE-common table EXP

WITH CTE1 (name ,studentID ,name ,date ,rmg) AS ( SELECT studentID ,name ,date ,CASE WHEN (ISNUMERIC(REPLACE(ldd.Value, '%', '')) =0) THEN 'NONE' WHEN (CONVERT(FLOAT,REPLACE(ldd.Value, '%', '')) >...

View Article

Query Execution Length

Hi, I'm a relative newcomer to SQL so apologies if this is stupid or obvious. I'm trying to write a query but am a bit stumped about the execution performance blowing up at what seems to me a pretty...

View Article

ITVFs, CTEs, and temp tables

I have a stored procedure in which a chain of temp tables is used. I want to convert the sproc to a ITVF, but of course temp tables can't be used in ITVFs. So I converted my chain of temp tables to a...

View Article


I need to write a query that will find a certain value, go up 2 rows above...

Hello all once again, I need help in writing a query. Please look at the ProductIdentifier Row below. I have inserted a column called LineItemInIIFFile. I need to write a code that will: 1. Find each...

View Article

I need serious help in changing the vaue of a column within the same column...

Hello to all, I am a DBA of 8 months so please bear with me. I am working on this prject for the company I am currently with for the past 4 months and I am almost finished. This is one of the last...

View Article


Better way to write correlated subquery

I've tried to ways to write this query, one with CTE. I'm wondering if this is a better way to write this, especially with the correlated sub-queries. TRY 1: SELECT O.OrderID, O.UserID,...

View Article

Update locking behaviour

I have a confusion regarding update locks in combination with CTE's (or subqueries) as in the following simple example - ;with CTE1 as (select material_code, quantity from MtrlStockTable **with...

View Article


Recursive Query Optimization

Hi, I had a table called Person with the columnname (person_id, person_name,person_permenant_address). I need to create a model . so to reduce my effort i planned to create a query which returns an...

View Article

Cte to count then update table

I have three tables items, orders and customers. The items table have product category fields (5 different products) and the orders table have order number sand order dates. If a customer orders five...

View Article

LIKE, IN, and a Subquery in a Single SQL Statement

Hello everyone, I am writing a query in which I am trying to search a subquery/CTE for a wildcard substring, and nesting this logic in my CASE statement. For example: SELECT CASE WHEN '%' + text + '%'...

View Article
Browsing all 75 articles
Browse latest View live




Latest Images