Tagged Questions
4
votes
1answer
566 views
CTE memory space [closed]
How do CTE memory space work? When you have complex SQL statements executing with the CTE and you get unusually large result set, can it increase the logical reads of the query?
I have a CTE that is ...
3
votes
1answer
69 views
Avoiding repetition without creating a view
Suppose that I have a query Q1 and I need to run a query like the following:
Q1
union
select *
from (some query that uses Q1 outcome)
I would like to do that:
Without creating any view
Without ...
3
votes
1answer
152 views
Retrieving queries when the hour of starting timestamp is less than the hour of ending timestamp
I have a CTE-based query in which I retrieve hourly intervals between two given timestamps. My query works as following:
Getting start and end datetimes (let's say 07-13-2011 10:21:09 and 07-31-2011 ...
1
vote
1answer
111 views
Thought CTEs were syntactic sugar
I was asked to test a change to a query, moving a Table Valued Function (TVF) into a CTE (non-recursive). My understanding was that each CTE reference is executed separately, so there was a ...
4
votes
4answers
517 views
CTE Running in Infinite Loop
My CTE runs in an infinite loop for a specific customer and I am not able to find out why.
Here is the query:
;WITH ClassTree
AS (SELECT ID, NAME, Parent_ID
FROM ...
5
votes
4answers
547 views
Multiple operations using WITH
Is there a way to execute multiple operations using the WITH statement?
Something like
WITH T AS
(
SELECT * FROM Tbl
)
BEGIN
OPEN P_OUTCURSOR FOR
SELECT * FROM T;
SELECT COUNT(*) INTO ...
4
votes
1answer
534 views
How to get text for default language
I have so tables:
and so data at Language table:
and so data at Text table:
I have to return text for requested language if it exists and text for default language if it does not exist. Is it ...
3
votes
1answer
263 views
SQL Server CTE problem
This question is in reference to my last question: SQL Server 08: Union over while
I'm writing a CTE to do what was described in that question (find available time slots over a given number of days.
...