Viewing 15 posts - 76 through 90 (of 125 total)
Think I finally solved this, went with a different tact started by finding the Min and Max dates by product by day and using the numbers function to produce 30min...
March 21, 2014 at 9:17 am
Do you have the DDL for these tables and some sample data?
March 20, 2014 at 10:45 am
Right, been able to spend a bit more time on this and revisit and the good news is seems I have something workable uses Luis's code
IF OBJECT_ID(N'dbo.VW_AmendmentsGroupTest1',N'V') IS NOT NULL
DROP...
March 20, 2014 at 6:20 am
May also be worth taking a look at using the OUTPUT clause in place of SCOPE_IDENTIY and @@Identity as well
March 17, 2014 at 9:57 am
And to answer luis's question I was originally basing it on 30mins from the first amendment, although again had loosely thought about resetting it and taking it as 30mins from...
March 14, 2014 at 2:26 am
Thanks guys I'll take a look at these this morning.
The 'requirements' as such aren't set in concrete, 30mins was just a finger in the air estimate on my behalf of...
March 14, 2014 at 2:21 am
Think I'm getting closer:
WITH GroupTime (Style,GrpDT)
AS
(
SELECTAT.Style,
DATEADD(HOUR,DATEDIFF(HOUR,0,DATEADD(MINUTE,30,AT.DT)),0)
FROM#AmendTest AS AT
GROUP
BYAT.Style,
DATEADD(HOUR,DATEDIFF(HOUR,0,DATEADD(MINUTE,30,AT.DT)),0)
),
DeriveNew (AmendmentID,Style,GrpDT,GrpNum)
AS
(
SELECTAT.AmendmentID,
AT.Style,
CA1.GrpDT,
DENSE_RANK() OVER (PARTITION BY AT.Style ORDER BY CA1.GrpDT ASC)
FROM#AmendTest AS AT
CROSS APPLY (SELECT DATEADD(HOUR,DATEDIFF(HOUR,0,DATEADD(MINUTE,30,AT.DT)),0)) AS CA1(GrpDT)
INNER
JOINGroupTime GT
ONAT.Style = GT.Style
AND CA1.GrpDT = GT.GrpDT
),
StyleCnt...
March 13, 2014 at 10:53 am
Sean Lange (3/12/2014)
Keith Tate (3/12/2014)
BTW Shan, Sean is one of the SQL Ninjas 😀
Thanks Keith. I would not consider myself a SQL Ninja by any means but thanks for the...
March 12, 2014 at 10:14 am
I think I may have misunderstood - if you want it to always be the 30th of each month with the exception of Feb, does what you have not work...
February 21, 2014 at 2:51 am
I'm assuming you would like the last day of the month? (March 31st?)
SELECTDATEADD(dd,-1,DATEADD(mm,DATEDIFF(m,0,GETDATE())+N,0))
FROMDBO.GetNums(1,12)
February 21, 2014 at 2:46 am
As a side note, is your syntax not incorrect for the UPDATE statement?
UPDATEParts
SET[TimeToTest] = 0.5000
WHEREPartID = 48871;
February 14, 2014 at 9:38 am
If you're using a lot of dates where the range can vary from say days to weeks/months/years it's likely the plan being used isn't optimal if the parameters being passed...
February 13, 2014 at 9:04 am
I'm guessing it's going to be an issue with parameter sniffing
How are you running the dynamic SQL? Adding your values to a string and then using
EXEC(@SQL)
or a parameterized query like:...
February 13, 2014 at 8:12 am
Bit hard for me to check if this works, but what you're looking to do is populate a variable with the returned result from the query. At the moment you're...
January 19, 2014 at 6:42 am
Viewing 15 posts - 76 through 90 (of 125 total)