Viewing 15 posts - 2,761 through 2,775 (of 10,143 total)
James.Rivers (12/3/2014)
I wanted to avoid creating a temp table for this process so I have opted to use the
SELECT LocationId, MaterialId, Duration
FROM (
SELECT LocationId,...
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
December 3, 2014 at 9:34 am
Andrew Kernodle (12/3/2014)
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
December 3, 2014 at 9:31 am
Have you tried sending the whole query to the linked server, something like this?
SELECT *
FROM OPENQUERY([mhsvi-sql2012a\instance1],
'SELECT
CONCAT(CONVERT(varchar(5),LEFT(IMADD.Postcode, 5),101)
,
''/''
,
CASE
WHEN x.Age <= 24 THEN ''A''
WHEN x.Age BETWEEN 25 AND 34 THEN...
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
December 3, 2014 at 6:47 am
or
SELECT LocationId, MaterialId, Duration
FROM (
SELECT LocationId, MaterialId, Duration,
VAR(Duration) OVER (partition by MaterialID) AS VarDuration
FROM #t
) d
WHERE VarDuration > 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
December 3, 2014 at 6:12 am
-- Sample data
IF OBJECT_ID ('tempdb..#Locations') IS NOT NULL DROP TABLE #Locations
CREATE TABLE #Locations (LOCATIONID VARCHAR(5), MATERIALID VARCHAR(5), DURATION SMALLINT)
INSERT INTO #Locations VALUES
('PlayM', 'Clip1', 626),
('PlayB', 'Clip1', 626),
('Ing', 'Clip1', 626),
('PlayM', 'Clip2',...
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
December 3, 2014 at 4:51 am
andrew_dale (12/2/2014)
A person born on 2012-02-29 should be how old on 2014-02-28?
1 year old still, the day has not rolled over to 1st March
select '20120228' , FLOOR((CONVERT(INT,'20140228') - CONVERT(INT,'20120228'))/10000) ,...
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
December 2, 2014 at 6:22 am
dave.ott 20779 (12/2/2014)
I've always liked this to get the age in yearsselect cast(datediff(d,@dob,getdate())/365.25 as int)
Try any date pair (DOB and reference date) where the month and the day are the...
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
December 2, 2014 at 6:08 am
andrew_dale (12/2/2014)
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
December 2, 2014 at 6:01 am
Yes it is. Why not code it up as an inline table-valued function instead of a UDF? You're likely to get far better performance. Get the query to work and...
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
December 1, 2014 at 4:45 am
Boby B Jacob (11/27/2014)
ChrisM@Work (11/27/2014)
If you can provide some readily-consumable sample data, someone will be more likely to put together a query for you.
Hi Chris, scenario is made available by...
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
November 27, 2014 at 5:29 am
vignesh.ms (11/27/2014)
...1. Why scan happens before the join occurs? if it happens after join then the filter would be lighter. Even if optimizer chooses the scan to execute first....
You have...
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
November 27, 2014 at 5:07 am
If you can provide some readily-consumable sample data, someone will be more likely to put together a query for you.
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
November 27, 2014 at 4:06 am
TomThomson (11/26/2014)
Hugo Kornelis (11/26/2014)
The code in option 2 will always do two lookups. One for the EXISTS, and then another one...
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
November 26, 2014 at 7:23 am
skanker (11/26/2014)
I can see now from the discussion that this was testing other things - however based on just the question...
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
November 26, 2014 at 6:39 am
An alternative to Luis' method:
SELECT
e.*,
x.Addresscode, x.AddressType, x.[Address]
FROM #employee e
OUTER APPLY (
SELECT TOP 1 *
FROM #EmpAddress a
WHERE a.Eid = e.Eid
ORDER BY AddressType, Addresscode
) x
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
November 26, 2014 at 4:21 am
Viewing 15 posts - 2,761 through 2,775 (of 10,143 total)