Viewing 15 posts - 4,321 through 4,335 (of 10,143 total)
Use an inline tally table as a row generator. Generate the week-based rows and the month-based rows separately:
DROP TABLE #dates
CREATE TABLE #dates (date_debut DATE,date_end DATE)
DECLARE @date_start DATE, @date_end DATE,...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 22, 2013 at 5:24 am
John Mitchell-245523 (7/22/2013)
Two options - the first being vastly more preferable:
(1) Don't store...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 22, 2013 at 4:45 am
Can you provide more information about the context please Ananth? For instance, are you designing a validation process for an import of a text-typed date?
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 22, 2013 at 4:08 am
jerome.morris (7/19/2013)
Ok Chris, I think I understand, but when I remove the simple data based on my table and use the real table it returns no results
It does return results:
ChrisM@Work...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 22, 2013 at 2:13 am
There's scope for improvement but without ddl/execution plan it's a long shot. Try this:
SELECT
t.TradeId,
CASE WHEN x.OtpTradeId IS NULL THEN 'Y' Else 'N' End As 'TCM'
FROM Trade t
OUTER APPLY...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 19, 2013 at 7:37 am
It creates a CTE consisting of a single datetime column - a very simple sample data set of your docket table.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 19, 2013 at 7:26 am
krypto69 (7/19/2013)
geez..thanks Chris...need to get some coffee..
Can I have some too? 🙂
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 19, 2013 at 7:16 am
What was the problem again? 😀
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 19, 2013 at 7:15 am
You're renamed the column to [Earn Code] in the inner select.
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 19, 2013 at 7:14 am
Cool, now post this code into the same ssms window underneath the rest of the code and run the lot as one batch:
SELECT *
FROM dbo.DocketTB
CROSS APPLY (
SELECT MondayLastWeek =...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 19, 2013 at 7:09 am
Steve-3_5_7_9 (7/19/2013)
kapil_kk (7/19/2013)
NO you cant add the IDENTITY property to the existing column using a sql query....But it can be done from edit design of a table
Of course you can....
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 19, 2013 at 6:43 am
Curious...ok, paste this whole batch into a new ssms window and execute:
DECLARE @RangeStart DATETIME, @RangeEnd DATETIME
SELECT
@RangeStart = x1.MondayLastWeek,
@RangeEnd = DATEADD(DD,7,x1.MondayLastWeek)
FROM (
SELECT MondayLastWeek = DATEADD(hh,7,CAST(CAST(DATEADD(DD,-((DATEDIFF(DD,0,GETDATE())%7)+7),GETDATE()) AS DATE) AS DATETIME))
)...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 19, 2013 at 6:39 am
Like this?
With subCA As (
Select distinct
OTPTradeId,
ConfoAuditSenderRef
from ConfirmationAudit
where ConfoAuditSenderRef like 'HBEUM%'
),
TCM As (
Select distinct
OTPTradeID
from subCA
union ALL
select TradeId
from subCA
inner join ConfirmationSent
on...
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 19, 2013 at 6:21 am
jerome.morris (7/19/2013)
Point taken Chris, but even if I did I wouldn't get results as I don't them in in the SSMS query?
Check:
SELECT TOP 100 Docket_EngFinish
FROM DocketTB
ORDER BY Docket_EngFinish DESC
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 19, 2013 at 6:10 am
jerome.morris (7/19/2013)
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
July 19, 2013 at 5:59 am
Viewing 15 posts - 4,321 through 4,335 (of 10,143 total)