JMac
2012-01-28 17:54:25 UTC
I just recently upgraded from SQL 2005 Standard to SQL 2008 Standard.
I have several views that were created in 2005 years ago and have
worked with no problems. When I run the views in SSMS 2008 I get a
time out error. When I run the views in the original VS 2005 report
they all work fine, but take several minutes to complete in the
upgraded VS 2008 report. Below is one of the views. Does anyone have
any ideas ?
Thanks
SELECT TOP (100) PERCENT CONVERT(CHAR(10),
dbo.ShiftSchedule.EndTime, 121) AS ShiftDate,
dbo.ShiftSchedule.ShiftName, COUNT(*) AS Count,
dbo.ShiftPeriodDetails.TargetProduction,
dbo.ShiftPeriodDetails.ShiftPeriod, dbo.ShiftPeriodDetails.SortOrder,
MIN(dbo.ProductionTracking.CSNID)
AS MinCSN, MAX(dbo.ProductionTracking.CSNID) AS
MaxCSN, dbo.ShiftPeriodDetails.HourofDay
FROM dbo.ShiftSchedule INNER JOIN
dbo.ProductionTracking ON
dbo.ShiftSchedule.StartTime <= dbo.ProductionTracking.a_Timestamp AND
dbo.ShiftSchedule.EndTime >
dbo.ProductionTracking.a_Timestamp RIGHT OUTER JOIN
dbo.ShiftPeriodDetails ON DATEPART(hour,
dbo.ProductionTracking.a_Timestamp) = dbo.ShiftPeriodDetails.HourofDay
GROUP BY CONVERT(CHAR(10), dbo.ShiftSchedule.EndTime, 121),
dbo.ShiftSchedule.ShiftName, dbo.ShiftPeriodDetails.TargetProduction,
dbo.ShiftPeriodDetails.ShiftPeriod,
dbo.ShiftPeriodDetails.SortOrder, dbo.ShiftPeriodDetails.HourofDay
ShiftSchedule Table
ID StartTime
EndTime ShiftName
5733 1/28/2012 3:00:00 PM 1/28/2012 11:00:00 PM Afternoons
5732 1/28/2012 7:00:00 AM 1/28/2012 3:00:00 PM Days
5731 1/27/2012 11:00:00 PM 1/28/2012 7:00:00 AM Nights
5730 1/27/2012 3:00:00 PM 1/27/2012 11:00:00 PM Afternoons
5729 1/27/2012 7:00:00 AM 1/27/2012 3:00:00 PM Days
5728 1/26/2012 11:00:00 PM 1/27/2012 7:00:00 AM Nights
ShiftPeriodDetails Table
ID ShiftPeriod TotalDur AvailDur TargetPro ShiftName
HourofDay SortOrder
1 7:00-8:00 60 56 66 Days 7 9
2 8:00-9:00 60 59 69 Days 8 10
3 9:00-10:00 60 50 59 Days 9 11
4 10:00-11:0060 59 69 Days 10 12
5 11:00-12:0060 40 47 Days 11 13
6 12:00-1:00 60 59 69 Days 12 14
7 1:00-2:00 60 50 59 Days 13 15
8 2:00-3:00 60 59 69 Days 14 16
9 3:00-4:00 60 56 66 Days 15 17
10 4:00-5:00 60 59 69 Days 16 18
11 5:00-6:00 60 50 59 Days 17 19
12 6:00-7:00 60 59 69 Days 18 20
13 7:00-8:00 60 40 47 Days 19 21
14 8:00-9:00 60 59 69 Days 20 22
15 9:00-10:00 60 50 59 Days 21 23
16 10:00-11:0060 59 69 Days 22 24
17 11:00-12:0060 56 66 Days 23 1
18 12:00-1:00 60 59 69 Days 0 2
19 1:00-2:00 60 50 59 Days 1 3
20 2:00-3:00 60 59 69 Days 2 4
21 3:00-4:00 60 40 47 Days 3 5
22 4:00-5:00 60 59 69 Days 4 6
23 5:00-6:00 60 50 59 Days 5 7
24 6:00-7:00 60 59 69 Days 6 8
ProductionTracking Table
ID CSNID a_TimeStamp
BuildCode
1082746 1474963 1/28/2012 12:35:32 PM 12
1082745 1474962 1/28/2012 12:34:40 PM 281
1082744 1474961 1/28/2012 12:33:53 PM 282
1082743 1474960 1/28/2012 12:33:06 PM 281
1082742 1474959 1/28/2012 12:31:47 PM 11
1082741 1474958 1/28/2012 12:30:48 PM 12
1082740 1474957 1/28/2012 12:30:18 PM 12
1082739 1474956 1/28/2012 12:29:22 PM 43
I have several views that were created in 2005 years ago and have
worked with no problems. When I run the views in SSMS 2008 I get a
time out error. When I run the views in the original VS 2005 report
they all work fine, but take several minutes to complete in the
upgraded VS 2008 report. Below is one of the views. Does anyone have
any ideas ?
Thanks
SELECT TOP (100) PERCENT CONVERT(CHAR(10),
dbo.ShiftSchedule.EndTime, 121) AS ShiftDate,
dbo.ShiftSchedule.ShiftName, COUNT(*) AS Count,
dbo.ShiftPeriodDetails.TargetProduction,
dbo.ShiftPeriodDetails.ShiftPeriod, dbo.ShiftPeriodDetails.SortOrder,
MIN(dbo.ProductionTracking.CSNID)
AS MinCSN, MAX(dbo.ProductionTracking.CSNID) AS
MaxCSN, dbo.ShiftPeriodDetails.HourofDay
FROM dbo.ShiftSchedule INNER JOIN
dbo.ProductionTracking ON
dbo.ShiftSchedule.StartTime <= dbo.ProductionTracking.a_Timestamp AND
dbo.ShiftSchedule.EndTime >
dbo.ProductionTracking.a_Timestamp RIGHT OUTER JOIN
dbo.ShiftPeriodDetails ON DATEPART(hour,
dbo.ProductionTracking.a_Timestamp) = dbo.ShiftPeriodDetails.HourofDay
GROUP BY CONVERT(CHAR(10), dbo.ShiftSchedule.EndTime, 121),
dbo.ShiftSchedule.ShiftName, dbo.ShiftPeriodDetails.TargetProduction,
dbo.ShiftPeriodDetails.ShiftPeriod,
dbo.ShiftPeriodDetails.SortOrder, dbo.ShiftPeriodDetails.HourofDay
ShiftSchedule Table
ID StartTime
EndTime ShiftName
5733 1/28/2012 3:00:00 PM 1/28/2012 11:00:00 PM Afternoons
5732 1/28/2012 7:00:00 AM 1/28/2012 3:00:00 PM Days
5731 1/27/2012 11:00:00 PM 1/28/2012 7:00:00 AM Nights
5730 1/27/2012 3:00:00 PM 1/27/2012 11:00:00 PM Afternoons
5729 1/27/2012 7:00:00 AM 1/27/2012 3:00:00 PM Days
5728 1/26/2012 11:00:00 PM 1/27/2012 7:00:00 AM Nights
ShiftPeriodDetails Table
ID ShiftPeriod TotalDur AvailDur TargetPro ShiftName
HourofDay SortOrder
1 7:00-8:00 60 56 66 Days 7 9
2 8:00-9:00 60 59 69 Days 8 10
3 9:00-10:00 60 50 59 Days 9 11
4 10:00-11:0060 59 69 Days 10 12
5 11:00-12:0060 40 47 Days 11 13
6 12:00-1:00 60 59 69 Days 12 14
7 1:00-2:00 60 50 59 Days 13 15
8 2:00-3:00 60 59 69 Days 14 16
9 3:00-4:00 60 56 66 Days 15 17
10 4:00-5:00 60 59 69 Days 16 18
11 5:00-6:00 60 50 59 Days 17 19
12 6:00-7:00 60 59 69 Days 18 20
13 7:00-8:00 60 40 47 Days 19 21
14 8:00-9:00 60 59 69 Days 20 22
15 9:00-10:00 60 50 59 Days 21 23
16 10:00-11:0060 59 69 Days 22 24
17 11:00-12:0060 56 66 Days 23 1
18 12:00-1:00 60 59 69 Days 0 2
19 1:00-2:00 60 50 59 Days 1 3
20 2:00-3:00 60 59 69 Days 2 4
21 3:00-4:00 60 40 47 Days 3 5
22 4:00-5:00 60 59 69 Days 4 6
23 5:00-6:00 60 50 59 Days 5 7
24 6:00-7:00 60 59 69 Days 6 8
ProductionTracking Table
ID CSNID a_TimeStamp
BuildCode
1082746 1474963 1/28/2012 12:35:32 PM 12
1082745 1474962 1/28/2012 12:34:40 PM 281
1082744 1474961 1/28/2012 12:33:53 PM 282
1082743 1474960 1/28/2012 12:33:06 PM 281
1082742 1474959 1/28/2012 12:31:47 PM 11
1082741 1474958 1/28/2012 12:30:48 PM 12
1082740 1474957 1/28/2012 12:30:18 PM 12
1082739 1474956 1/28/2012 12:29:22 PM 43