Viewing 15 posts - 6,841 through 6,855 (of 10,144 total)
yatish.patil (7/12/2011)
Thank you for your query Solution, but when I tested the output for the data as below.
...
You can see the difference between both. Thank you for...
July 12, 2011 at 4:54 am
;WITH Calculator1 AS (
SELECT Historyid, ID, LetterNo, letter,
rn1 = ROW_NUMBER() OVER(ORDER BY Historyid),
rn2 = ROW_NUMBER() OVER(PARTITION BY Letter ORDER BY Historyid)
FROM #Test),
Calculator2 AS (
SELECT Historyid, ID, LetterNo,...
July 12, 2011 at 4:41 am
Facebook is awesome for retaining a link with distant relatives. I have cousins in Canada and Hong Kong (and family scattered all around the UK) and FB lets me keep...
July 12, 2011 at 2:59 am
Here's another APPLY solution:
DROP TABLE #Strings
CREATE TABLE #Strings (Longstring VARCHAR(150))
INSERT INTO #Strings (Longstring) values ('SABRE a CIRCUIT BREAKER MOTORISATION SCHEMATIC DIAGRAM, FOR USE WITH MICOM & A MULTI VOLTAGE SHUNT...
July 11, 2011 at 9:45 am
Daniel Bowlin (7/11/2011)
falling behind
It's all going South sooner or later.
July 11, 2011 at 8:03 am
John Mitchell-245523 (7/7/2011)
... the value will be updated with all the values, leaving the one that was done last as the value that persists...
From BOL UPDATE section: "...This is because...
July 7, 2011 at 7:05 am
SQLkiwi (7/7/2011)
July 7, 2011 at 6:39 am
SQLkiwi (7/7/2011)
There's no need for a join at all - a point I realised after editing the TOP trick into your code. I have updated the code and...
July 7, 2011 at 5:50 am
The new version runs faster but not by much.
So the optimizer converts what looks like a triangular join (the entire CROSS APPLY part) into a TOP query?
Interestingly, you can...
July 7, 2011 at 5:36 am
Nice one, Paul. The triangular join put me off writing and testing it, but in practice the performance is stunningly good - half a million rows return in 12s on...
July 7, 2011 at 4:47 am
Craig Farrell (7/6/2011)
Jeff Moden (7/6/2011)
Chris,Do you know of a way to use the rCTE to do a running total without the ID's being perfectly sequential?
There's a way using Cross Apply...
July 7, 2011 at 2:04 am
tommey152 (7/6/2011)
Hi ,.....
Is there any SQL statement that can do this easily? What's the best way to accomplish this?
Easiest is the recursive CTE:
DROP TABLE #SourceData
CREATE TABLE #SourceData (id INT...
July 6, 2011 at 6:57 am
-- simplest
SELECT *
FROM t
WHERE YEAR(CASE
WHEN t.[type] = 'import' THEN t.arrdate
WHEN t.[type] = 'export' THEN t.depdate
ELSE NULL END) = YEAR(@deparr)
-- possibly faster
SELECT *
FROM t...
July 1, 2011 at 9:07 am
SQLkiwi (6/30/2011)
ChrisM@Work (6/30/2011)
...code...
Hi Chris,
You might be interested in a slight tweak to that code. Take a look at the query plans for these:
...
Notice the special distinct sort in the...
July 1, 2011 at 2:05 am
Viewing 15 posts - 6,841 through 6,855 (of 10,144 total)