Viewing 15 posts - 4,681 through 4,695 (of 10,143 total)
How about a sample table script?
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
May 1, 2013 at 9:15 am
Sean Lange (5/1/2013)
ChrisM@Work (5/1/2013)
Sean Lange (5/1/2013)
I would suggest you use the newer join constructs. With this query you don't even need a where clause.
Here...
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
May 1, 2013 at 8:11 am
Sean Lange (5/1/2013)
I would suggest you use the newer join constructs. With this query you don't even need a where clause.
Here is the syntax:
from...
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
May 1, 2013 at 7:48 am
kabaari (5/1/2013)
select s.partNo, p.descript,sum(case when battState = '99' then qty else '0'end) as CLNT,
sum(case when battState = '1' then qty-newQty else '0'...
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
May 1, 2013 at 7:46 am
Where's [NewQty]?
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
May 1, 2013 at 7:38 am
todd.ayers (4/30/2013)
LOL!! yeah sorry hope I didnt offend you?
Heck no!
Have you tested the code yet?
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
May 1, 2013 at 7:10 am
KoldCoffee (5/1/2013)
In the real world case I have several CTEs in each statement. ie. ct1, followed by ct2, followed by final select. Which CTE...
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
May 1, 2013 at 7:04 am
You should consider replacing the slow slow cursor with a fast set-based equivalent:
UPDATE a SET
Transferred = 'Y'
OUTPUT
a.LoanTypeId,
a.LoanAmount,
a.LoanRate,
a.LoanYears,
MonthlyPayment = a.LoanAmount/(y.Result-1) * (a.LoanRate*y.Result),
a.[Status]
INTO Loans
FROM Applications a
CROSS APPLY (SELECT NumberOfPeriods...
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
May 1, 2013 at 6:46 am
...
/**Check if Loan exists**/
SELECT @RowCount = Count(*)
FROM Applications
WHERE ApplicationID = @ApplicationID
IF @RowCount = 0
BEGIN
PRINT 'Applicación' + @ApplicationID + ' no está aprobada o activa';
ROLLBACK TRANSACTION -- complete the transaction...
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
May 1, 2013 at 6:28 am
KoldCoffee (5/1/2013)
thanks for reply. I should have posted what the result set was that I'm after. There should be two rows for each person, one recording total count of...
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
May 1, 2013 at 6:20 am
Left join the scores table to the weeks table. If you mock up sample data scripts, folks will show you exactly how.
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
May 1, 2013 at 6:03 am
Beatrix Kiddo (5/1/2013)
Cool, thanks. I've amended it to.
and LEN(CURRENT_POINT) > 0🙂
Is there any reason not to use this? CURRENT_POINT > ' '
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
May 1, 2013 at 3:39 am
Beatrix Kiddo (5/1/2013)
Ah, ChrisM@Work, I think I get what you were saying now.
and LEN(LTRIM(RTRIM(CURRENT_POINT))) > 0Seems to have fixed it.
Thanks all!
LEN ignores leading spaces, you don't need to trim. However,...
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
May 1, 2013 at 3:27 am
Beatrix Kiddo (5/1/2013)
I'm trying...
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
May 1, 2013 at 2:43 am
create table #temp (ID int, Name varchar(20))
insert into #temp
values
(10, 'Helen'),
(20, 'Joe'),
(30, 'Blake');
;WITH OnlyHelen AS (
SELECT CTE = 1, *
FROM #temp
WHERE Name = 'Helen'
),
ExceptHelen AS (
SELECT CTE = 2,...
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
May 1, 2013 at 1:43 am
Viewing 15 posts - 4,681 through 4,695 (of 10,143 total)