Viewing 11 posts - 1 through 11 (of 11 total)
Full disclosure, I attempted to convert from this function I wrote 10 years ago, but am getting the math wrong now. - I'm pretty sure each part in this script...
February 20, 2018 at 7:13 pm
Wait, still wrong... I'll reply once I fix it
February 20, 2018 at 6:43 pm
you're right - my bad, the "DECLARE @RtrnDt" should be:
DECLARE @RtrnDt DATE = DATEADD(DAY,((CEILING((CONVERT(DECIMAL(8, 2),17) % DATEPART(dw, @1st)) / 10) * 7) + ((@Itr*7)+@DOW+1)-7) - DATEPART(dw, @1st), @1st);
February 20, 2018 at 6:34 pm
I've had a need to do similar block style within one column of the output, I used the FOR XML trick - something like:
SELECT aa.ID
, Stuff((Selectchar(10)+char(13)+
'ID:' + isnull(iaa.ID,'N/A')
+...
January 29, 2014 at 1:43 pm
Here's a function I wrote to convert from central time to GMT (CST or CDT to UTC in other words) - might help:
Create FUNCTION [dbo].[udfConvertToGMT]
(@InputDate datetime)
RETURNS datetime
AS
/*
Script Date: 08/11/2009
Author:...
March 31, 2010 at 12:05 pm
The Case statement in the where clause could cause performance issues if you're dealing with larger databases, I've been able to get away with using it more often than not...
March 31, 2010 at 11:51 am
From the sound of it you could probably use Case statements. Here's an example:
Declare @var int --decides which parts of where clause to use
,@var2 varchar(20)
,@var3 varchar(20)
Select...
March 30, 2010 at 3:01 pm
You shouldn't really be comparing an int (0) to char data (space(0)).
The reason behind these evaluating as true (and the reason behind space(0) comparing equaly to space(1,2,3, ect..) can...
March 30, 2010 at 11:24 am
Another way to do it (if I'm understanding what your looking for correctly):
SELECT @rcount=Count(*)
FROM Table
WHERE
variable1=@variable1
AND Case when isnull(@variable2,'')='' then 1
Else...
March 30, 2010 at 8:06 am
How bout something like this?
;With prnt (id, mpid,lvl) AS
(Select d.id,isnull(d.idxref,d.Id),1
From #Data d
UNION ALL
Select d.id, p.mpid,p.lvl+1
From #Data d
Inner Join prnt p
ond.IdXref = p.id
)
Select p.id,p.mpid
from prnt p
Inner Join (select id, max(lvl)...
March 29, 2010 at 12:41 pm
Never mind, I missed a \ in my script on the second server - it's always the little details that trip us up
December 11, 2008 at 8:32 am
Viewing 11 posts - 1 through 11 (of 11 total)