Viewing 15 posts - 151 through 165 (of 819 total)
Both filtered index and statistics suffer of parameterization in the where clause.
In the following query, the optimizer can't predict which filtered statistic should be used (think to stored procs).
declare @lan...
January 5, 2017 at 1:55 am
The correct answer is "depend" on numbers of records in the table:
With one or few records the correct answer is "09:00:10", but with many records (in my case 6800) the...
January 4, 2017 at 1:20 am
mlandry (12/22/2016)
CHAR(...) + 65 is far too dependent upon the shift labels A, B, C. If they changed to non-contiguous strings, then this is out the window.
Old "C" language trick.
December 22, 2016 at 9:49 am
Dohsan (12/22/2016)
CREATE FUNCTION [dbo].[ShiftCalc]
(
@ShiftTime DATETIME,
@ShiftStart DATETIME,
@NumOfShifts TINYINT
)
RETURNS TABLE WITH SCHEMABINDING
AS
RETURN
SELECT
OnShift = CHAR(ABS(DATEDIFF(DAY,@ShiftStart,DATEADD(HOUR,-DATEPART(HOUR,@ShiftStart), @ShiftTime))) % @NumOfShifts + 65);
GO
DECLARE @ShiftAStart DATETIME = '2006-01-01T07:00:00';
SELECTD.Incident,
CA1.OnShift
FROM(
VALUES(CAST('2006-01-01T07:00:00' AS DATETIME)),
('2006-01-01T17:00:00'),
('2006-01-02T06:00:00'),
('2006-01-02T07:00:00'),
('2006-01-02T23:00:00'),
('2006-01-03T07:00:00'),
('2006-01-03T09:00:00'),
('2006-01-04T07:00:00')
) AS D(Incident)
CROSS
APPLYdbo.ShiftCalc(D.Incident,@ShiftAStart,3) AS...
December 22, 2016 at 3:26 am
SET @compareDate = DATEADD(HOUR, -7, @ShiftDate)
SELECT CASE ABS(DATEDIFF(DD, @compareDate, @baseDate)) % 3
WHEN 0 .....
December 22, 2016 at 1:06 am
Thanks! I learned a real new and interesting feature!
December 20, 2016 at 1:07 am
Any select could be surrounded by parenthesis:
(select * from sys.objects WHERE name like 'sys%')
(select * from sys.indexes WHERE name like 'c%')
December 15, 2016 at 10:21 am
Stewart "Arturius" Campbell (11/14/2016)
However, as I am sure you are aware, the sequence is important:
if the query is changed toSELECT 0
UNION
SELECT 1
UNION
SELECT NULL
UNION ALL
SELECT NULL
UNION
SELECT 2;, the...
November 15, 2016 at 1:25 am
Steve Jones - SSC Editor (11/3/2016)
November 4, 2016 at 1:59 am
Despite of the confusion, it's a good question.
November 2, 2016 at 10:25 am
handkot (10/26/2016)
I think the answer is 5, can also be considered corrector am i wrong?
You're wrong!
CONCATENATE concatenates only two string. CONCATENATE(<text1>,<text2>)
CONCATENATEX concatenates ALL values of a table. See the...
October 27, 2016 at 1:02 am
Rune Bivrin (9/23/2016)
"The syntax of the batch is correct" is not really an output of the batch, but the conclusion of the parser. That message...
September 23, 2016 at 1:18 am
Viewing 15 posts - 151 through 165 (of 819 total)