Viewing 15 posts - 826 through 840 (of 2,171 total)
Beware of rounding!
If you run the suggested code PM, you will not get today's beginning.
Declare @Today smalldatetime
-- beginning of today:
Select @Today = Cast(Cast(getdate() as int) as smalldatetime)
Try...
July 11, 2008 at 12:53 pm
How do the query plan look like now?
July 9, 2008 at 11:51 am
Why the five almost identical LEFT JOINs?
SELECTLName,
FName,
Address1,
Address2,
City,
[State],
Zip,
Phone,
SSN,
0 AS [Basic],
x.EL AS Optional,
x.BAD AS EmployeeVADD,
x.VAD AS FamilyVADD,
x.SPL AS Spouse,
x.CHL AS Child,
DOB
FROMPersonalData
INNER JOINCensus ON Census.TrackingID = PersonalData.TrackingID
INNER JOINClientPlan ON ClientPlan.PlanID = Census.PlanID
INNER JOIN(
SELECTTrackingID,
MAX(CASE...
July 9, 2008 at 1:56 am
June 30, 2008 at 7:52 am
Jim, you believe that is easier than a recursive CTE?
Hari, where is the hierarchy?
DECLARE@Sample TABLE (NodeID INT, NodeName VARCHAR(20), ParentNodeID INT)
INSERT@Sample
SELECT 1,'HR',0 UNION ALL
SELECT 2,'Finance',0 UNION ALL
SELECT 3,'Production',0 UNION ALL
SELECT...
June 25, 2008 at 6:54 am
Tried this?
SELECT DENSE_RANK() OVER (PARTITION BY a.bus_manager_name, c.NumericFiscalWeek ORDER BY ISNULL(MAX(h.totalscore), 18) DESC) END AS QualityRank
June 25, 2008 at 2:12 am
Probably a recursive CTE.
Read Books Online how to write these kind of queries.
June 25, 2008 at 2:00 am
UPDATE Table1
SET Col1 = cast(convert(varchar(30), Col1, 120) AS datetime)
June 24, 2008 at 7:26 am
DECLARE@Sample TABLE
(
Site CHAR(1),
[Date] VARCHAR(5),
[Group] INT,
Page INT,
Position INT
)
INSERT@Sample
SELECT'a', '1/1', 1, 1, 5 UNION ALL
SELECT'a', '1/1', 2, 2, 6 UNION ALL
SELECT'b', '1/1', 1, 3, 7 UNION ALL
SELECT'b', '1/1', 2, 4, 8
SELECTSite,
[Date],
MAX(CASE WHEN...
June 24, 2008 at 1:03 am
You are right about table variables can't be used together with INSERT ... EXEC since this is a SQL 2000 forum.
But in SQL 2005 you can use a table variable...
June 24, 2008 at 12:57 am
HP 8710p laptop.
2.4 GHz Intel Centrino Pro
2gb ram.
Single sata 3.5" harddrive.
Microsoft SQL Server 2005 Developer Edition - 9.00.3215.00
If I tell you what I use at home, I have to kill...
June 23, 2008 at 9:06 am
Your original solution will also gain from preaggregration like this
-- Jeff 2
SELECTCompany,
[Year],
SUM(CASE WHEN [Quarter] = 1 THEN Amount ELSE 0.0 END) AS [Q1 Amt],
SUM(CASE WHEN [Quarter] = 1 THEN Quantity...
June 23, 2008 at 8:29 am
SELECTSourceID,
ProdID,
Bidder,
BidValue,
BidDate
FROM(
SELECTSourceID,
ProdID,
Bidder,
BidValue,
BidDate,
ROW_NUMBER() OVER (PARTITION BY SourceID ORDER BY BidValue DESC, BidDate) AS RecID
FROMTable
) AS d
WHERERecID = 1
June 23, 2008 at 8:23 am
The trick was not to convert CTE to derived table.
The performance gain was to subaggregate the table before making the pivot.
June 23, 2008 at 8:08 am
Viewing 15 posts - 826 through 840 (of 2,171 total)