Viewing 15 posts - 136 through 150 (of 812 total)
March 2, 2017 at 9:16 am
March 2, 2017 at 1:20 am
February 14, 2017 at 1:40 am
February 8, 2017 at 3:03 am
DBCC SHRINKFILE (N'mydb_log' , 0, TRUNCATEONLY)
February 8, 2017 at 1:59 am
Uncomment the query you want to try:WITH Fullname
AS
(
SELECT * FROM (VALUES
('Erin','Keri','Moody','Sr.')
,('Megan','Laura','Morales','B.S.')
,('George','Lena',NULL,'')
,(NULL,'Ryan','Lucas','M.D.')
,('Sheryl','Marianne','Morton','IV')
) AS V([firstname],[middlename],[lastname],[suffix])
)
--SELECT COALESCE
-- (
-- firstname,...
January 25, 2017 at 9:49 am
January 25, 2017 at 9:46 am
hakan.winther - Wednesday, January 25, 2017 2:28 AMThat was an easy one, thanks! You could also solve this query with CONCAT. 🙂
That's...
January 25, 2017 at 3:27 am
sendijunk (1/11/2017)
Good question. Could use a bit more explanation though. Interesting what happens if you replace ISNULL with COALESCE.
The return type depends on "precedence" of types. In this case, the...
January 11, 2017 at 1:20 am
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
Viewing 15 posts - 136 through 150 (of 812 total)