Viewing 15 posts - 586 through 600 (of 626 total)
Try using the CASE statements in the top level SELECT.
April 13, 2015 at 2:11 pm
Start here:
http://www.sqlservercentral.com/stairway/72399/
The stairway articles here are a great resource...but essentially a Clustered Index IS your table.
April 13, 2015 at 11:31 am
river1 (4/13/2015)
I have a view named SGSCC
If I call it as select * from SGSCC it works fine
If I try to call it as select * from sgcc says that...
April 13, 2015 at 7:43 am
Sean Lange (4/10/2015)
This is wrong on a couple of levels. The first is...
April 10, 2015 at 12:51 pm
Sorry I used the wrong date in the APPLY. It should have been this:
SELECT
DATEPART(wk, t.date) AS [Week],
t.*,
x.Sales52
FROM #Test t
OUTER APPLY
(
SELECT SUM(sales) AS Sales52
FROM #Test
WHERE
([Date] BETWEEN DATEADD (wk, -52, t.date)AND...
April 10, 2015 at 11:36 am
...or you can cheese it a bit and do
SELECT * FROM #TEST
SELECT
t.EmpCode,
oa.TimeIn,
t.Time AS [TimeOut]
FROM
#TEST t
OUTER APPLY(
SELECT MAX(Time) AS TimeIn FROM #TEST WHERE [TIME] < t.TIME AND [In/OUT] = 'TRUE'
) oa
WHERE
t.[In/Out]...
April 10, 2015 at 10:18 am
This will get you most of the way.
SELECT
t.EmpCode,
oa.TimeIn,
t.Time AS [TimeOut]
FROM
#TEST t
OUTER APPLY(
SELECT MAX(Time) AS TimeIn FROM #TEST WHERE [TIME] < t.TIME AND [In/OUT] = 'TRUE'
) oa
WHERE
t.[In/Out] = 'FALSE'
AND EmpCode =...
April 10, 2015 at 9:47 am
Are you looking for something like this?
WITH Last52 (Market, Item, Sales52)
AS
(
SELECT
Market,
Item,
SUM(sales) AS Sales52
FROM
#Test
WHERE
[Date] BETWEEN DATEADD (wk, -52, Date)AND GETDATE()
GROUP BY
Market,
Item
)
SELECT
DATEPART(wk, t.date) AS [Week],
t.*,
l.Sales52
FROM #Test t
JOIN Last52 l ON l.Market...
April 10, 2015 at 7:33 am
Shouldn't have any reason to move the step. Just apply the logging to the one in question.
Maybe try restarting the Agent and running again. I've seen my share...
April 10, 2015 at 7:08 am
Well the only thing left that I can think of is I sometimes forget to DROP or DELETE my temp tables when I testing some code. Maybe you ran...
April 9, 2015 at 2:13 pm
Yes, that is correct...see easy to make a typo. 😉
Hmmm...if it didn't return anything that is strange.
April 9, 2015 at 1:16 pm
How many steps do you have in your job and which one is reporting an error? The logging is applied to each step individually, so you'll need to make...
April 9, 2015 at 12:49 pm
Your select statement that you posted doesn't guarantee unique values for OrderID.
Just for fun just try:
SELECT
tinclude.OrderId,
COUNT(tinclude.OrderId)
FROM
( SELECT v.OrderId FROM dbo.mdv_CustomerFilterCustomerTransDate v WITH (NOLOCK)
WHERE v.TerritoryCode IN (3) AND v.CustomerId...
April 9, 2015 at 12:05 pm
Is that a typo in your Insert statement or did you forget the DISTINCT keyword?
INSERT INTO #Context( OrderId )
SELECT DISTINCT tinclude.OrderId FROM ( SELECT v.OrderId FROM dbo.mdv_CustomerFilterCustomerTransDate v WITH...
April 9, 2015 at 8:07 am
I've had similar issues in the past. The problem is often the errors are very vague. Try editing the advanced option on your job step to 'Include step...
April 9, 2015 at 7:54 am
Viewing 15 posts - 586 through 600 (of 626 total)