Viewing 15 posts - 181 through 195 (of 2,171 total)
It seems the dual TOP/ORDER BY was the most efficient approach by the time.
I tested the new Denali OFFSET/FETCH and I got the exact same number of reads for @StartRow...
December 6, 2010 at 8:15 pm
SELECTSTUFF(CONVERT(CHAR(10), GETDATE(), 101) + ' ' + SUBSTRING(CONVERT(CHAR(19), GETDATE(), 100), 13, 7), 15, 2, SUBSTRING(CONVERT(CHAR(8), GETDATE(), 8), 4, 5))
November 17, 2010 at 4:19 am
why? WHY?
A date is a datetime value, nothing else. What you want is a textual representation of a datetime value and you can accomplish that with CONVERT function. Look in...
November 17, 2010 at 1:38 am
In SQL Server the only three valid values for BIT is 1, 0 and NULL.
Only 0 will be interpreted as 0 and all other values will be treated as 1.
It's...
November 11, 2010 at 1:17 pm
SELECTinv.Reference AS 'Invoice Reference',
inv.InvoiceDate AS 'Invoice Date',
DATEPART(YEAR, inv.InvoiceDate) AS InvoiceYear,
DATEPART(MONTH, inv.InvoiceDate) AS InvoiceMonth,
DATEPART(WEEK, inv.InvoiceDate) AS InvoiceCalWeek,
MAX(serv.CreatedDate)
FROMdbo.SalesInvoices AS inv
INNER JOINdbo.SalesOrders AS sales ON sales.[UID] = inv.DocumentID
INNER JOINdbo.ServiceOrders AS serv ON serv.DocumentID...
November 8, 2010 at 4:39 am
CREATE FUNCTION dbo.fnGetMilitaryDate
(
@Sample DATETIME
)
RETURNSCHAR(5)
AS
BEGIN
RETURN(
SELECTSUBSTRING(DATENAME(YEAR, @Sample) + DATENAME(DAYOFYEAR, @Sample), 3, 5)
)
END
November 8, 2010 at 4:33 am
How does the distribution of ColY values look like?
If the distribution is somewhat even, consider making the partitioning key on ColY value.
Maybe 10 partitions, ranging 0-(10, 10-(20, 20-(30, 30-(40, 40-(50,...
November 5, 2010 at 7:33 am
I have another thought... In what range does ColY varies within?
0-100?
November 5, 2010 at 7:07 am
If you make the ColY clustered, inserting a new record into the clustered index will make the index reorganize and while doing so, the index is locked and since clustered...
November 5, 2010 at 7:05 am
Alter column ColX to be a bigint identity NONCLUSTERED primary key.
Alter column Coly to be a REAL clustered column.
Then your selects will be really speedy! 😀
But then again, inserting new...
November 5, 2010 at 6:49 am
SELECTo.*
FROM@Overlap AS o
CROSS APPLY(
SELECT*
FROM@Overlap AS x
WHEREx.infoname = o.infoname
AND x.id <> o.id
AND x.effective <= o.termination
and x.termination >= o.effective
) AS f
November 4, 2010 at 11:43 pm
How many records are we talking about? Maybe partitioning could help you.
How does the SELECT look like? Proper indexing will help you here.
November 4, 2010 at 7:22 am
You don't need a tvf here.
declare @pol_cd char(18), @val_date datetime
set @pol_cd = 'xx000000'
set @val_date = '2010/06/30'
...
November 3, 2010 at 6:27 am
Tom, that would be three simple steps
1) Replace 0 with '17530101'
2) Replace 6 with '17530107'
3) Replace 1900 with 1753
Done!
November 2, 2010 at 9:00 am
SELECTDATEADD(YEAR, DATEDIFF(YEAR, 0, GETDATE()) - d.Delta, 0) AS StartOfYear,
DATEADD(MONTH, 12 * DATEPART(YEAR, GETDATE()) - 22790 - 12 * d.Delta, 1) AS EndOfYear
FROM(
SELECT0 UNION ALL
SELECT1 UNION ALL
SELECT2 UNION ALL
SELECT3
) AS d(delta)
ORDER...
November 2, 2010 at 8:24 am
Viewing 15 posts - 181 through 195 (of 2,171 total)