Viewing 15 posts - 1 through 15 (of 125 total)
From what I can see, you're looking for the earliest start date and latest d date?
SELECT A.[From],
A.[To],
A.Company,
A.Vehicle,
MIN(A.StartDate),
MAX(A.EndDate)
FROM dbo.ExampleTable AS A
GROUP BY...
June 6, 2017 at 8:29 am
January 31, 2017 at 8:36 am
I had this snippet I used a while back, which may be of use to you. It gets the ID of the job based on the name and then starts...
January 31, 2017 at 8:05 am
I had similar issues myself a few weeks back (SQL SERVER 2008).
Data Flow task would run a stored procedure as the source, get a row count and then create a...
December 23, 2016 at 1:55 am
Could possibly remove the case
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);
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 CA1;
December 22, 2016 at 2:09 am
From what you're saying you want to replace all with 0s..
UPDATE TestTable_1
set datecolumn = '0000-00-00';
October 1, 2015 at 3:48 am
Does this do what you're after? Checks if there are less than 100 observations and then multiples the rank by a factor if needed
USE tempdb;
WITH CTE
AS
(
SELECT 100 Cust_ID ,...
September 16, 2015 at 5:21 am
The idea was to not make it dependent on the DATEFIRST setting and the basis there was no calendar table. Using DATEDIFF(DAY,0,@StartDate)%7 you know that 0 will always be the...
July 3, 2015 at 10:26 am
Alvin Ramard (7/3/2015)
Phil Parkin (7/3/2015)
Alvin Ramard (7/3/2015)
Why are you trying to make everything so complicated?
Avril Lavigne?
She would sound better right now. 😛
Why? Boredom! Not sure if Avril sings about that...
July 3, 2015 at 9:25 am
Alvin Ramard (7/2/2015)
vipin_jha123 (7/2/2015)
Hi,I am having one requirement where I want to show only first Friday of every month of 2014,2015 and 2016 year.
Please suggest me the logic
Regards,
Vipin jha
Try this...
July 3, 2015 at 2:14 am
sgmunson (7/2/2015)
vipin_jha123 (7/2/2015)
Using SQL Qury.
Here's a query that converts from numeric values, although if you want to just generate this data independent of other table values, then you could change...
July 2, 2015 at 9:32 am
This should work:
DECLARE @Chuff TABLE
(
Sub_Cat_ID INT NOT NULL,
BSNS_IDINT NOT NULL,
BSBS_PRFX VARCHAR(10) NOT NULL,
DO_ID INT NOT NULL
);
INSERT INTO @Chuff (Sub_Cat_ID,BSNS_ID,BSBS_PRFX,DO_ID)
VALUES (13,16,'cntcr',3),
(11,16,'cntcr',3),
(2058,1,'cntcr',3);
DECLARE @Chuff2 TABLE
(
seq INT NOT NULL,
Descr VARCHAR(25) NOT NULL
);
INSERT INTO @Chuff2...
July 2, 2015 at 7:40 am
A calendar table would be good here, although I think the code below should also do the job
DECLARE@StartDayDATETIME = '20140101',
@EndDayDATETIME = '20161231';
WITH DateBase (DT,RN)
AS
(
SELECTA.DT,
ROW_NUMBER() OVER (PARTITION BY YEAR(A.DT),MONTH(A.DT) ORDER BY...
July 2, 2015 at 4:44 am
Here's a start:
SET NOCOUNT ON
CREATE TABLE dbo.pf
(
codigo int not null PRIMARY KEY CLUSTERED,
pfstamp CHAR(1) not null
);
CREATE TABLE dbo.pfu
(
pfstamp CHAR(1) not null PRIMARY KEY CLUSTERED
);
INSERT INTO dbo.pf (codigo,pfstamp)
VALUES (1,'A'),
(2,'B'),
(4,'C'),
(10,''),
(11,'E'),
(13,'F');
INSERT INTO dbo.pfu...
June 25, 2015 at 4:03 am
Hi Luis,
Have you looked at the possible performance improvements of converting this into an inline table valued function (iTVF)?
June 25, 2015 at 3:47 am
Viewing 15 posts - 1 through 15 (of 125 total)