Hi Guys
When I try to Import data from SQL server through VBA, I get below, Can you please help me to eliminate this error.
Error = .Refresh BackgroundQuery:=False
My SQL Script as follows
When I try to Import data from SQL server through VBA, I get below, Can you please help me to eliminate this error.
Error = .Refresh BackgroundQuery:=False
My SQL Script as follows
Code:
DECLARE @Tel_StartDate INTEGER;
DECLARE @Tel_EndDate INTEGER;
SELECT @Tel_StartDate = '20140101';
SELECT @Tel_EndDate = '20140612';
SELECT
DimDate.[FullDate] as [Date],
DimManpower.[BusinessKey] AS [LAN ID],
DimManpower.[FirstName] + ' ' + DimManpower.[LastName] AS [Agent],
DimManLM.[FirstName] + ' ' + DimManLM.[LastName] AS [LineManager],
DimManOps.[FirstName] + ' ' + DimManOps.[LastName] AS [OpsManager],
DimManpowerDepartment.[DepartmentDescription] AS [Department],
DimManpowerSite.[SiteDescription] AS [Site],
CallGroup.[Name] as [Call Group],
CallType.[Name] as [Call Type],
SUM([Agent_Queue_Day].[Calls_Accepted]) AS [Accepted Calls],
CASE WHEN SUM([Agent_Queue_Day].[Calls_Accepted]) = 0 THEN 0 ELSE CAST(SUM([Agent_Queue_Day].[Time_Seconds_Talk]-[Agent_Queue_Day].[Time_Seconds_Hold]) AS FLOAT) / SUM([Agent_Queue_Day].[Calls_Accepted]) END AS [Avg Engage Time],
CASE WHEN SUM([Agent_Queue_Day].[Calls_Accepted]) = 0 THEN 0 ELSE CAST(SUM([Agent_Queue_Day].[Time_Seconds_Wrap]) AS FLOAT) / SUM([Agent_Queue_Day].[Calls_Accepted]) END AS [Avg Wrap Time],
CASE WHEN SUM([Agent_Queue_Day].[Calls_Accepted]) = 0 THEN 0 ELSE CAST(SUM([Agent_Queue_Day].[Time_Seconds_Handle]) AS FLOAT) / SUM([Agent_Queue_Day].[Calls_Accepted]) END AS [Avg Handle Time]
FROM
[DAVE_PL].[dbo].[FactInboundTelephony_Agent_Queue_Day] [Agent_Queue_Day] WITH(NOLOCK)
INNER JOIN [DAVE_PL].[dbo].[DimDate] ON Agent_Queue_Day.[DimDateKey] = DimDate.[DimDateKey]
INNER JOIN [DAVE_PL].[dbo].[DimSystem] ON Agent_Queue_Day.[DimSystemKey] = DimSystem.[DimSystemKey]
INNER JOIN [DAVE_PL].[dbo].[DimManpower] ON Agent_Queue_Day.[DimManpowerKey] = DimManpower.[DimManpowerKey]
INNER JOIN [DAVE_PL].[dbo].[DimManpowerSite] ON DimManpower.[SiteKey] = DimManpowerSite.[DimManpowerSiteKey]
INNER JOIN [DAVE_PL].[dbo].[DimManpowerDepartment] ON DimManpower.[DepartmentKey] = DimManpowerDepartment.[DimManpowerDepartmentKey]
INNER JOIN [DAVE_PL].[dbo].[DimManpowerActivity] ON DimManpower.[ActivityKey] = DimManpowerActivity.[DimManpowerActivityKey]
INNER JOIN [DAVE_PL].[dbo].[DimManpowerGrade] ON DimManpower.[GradeKey] = DimManpowerGrade.[DimManpowerGradeKey]
INNER JOIN [DAVE_PL].[dbo].[DimManpowerStatus] ON DimManpower.[StatusKey] = DimManpowerStatus.[DimManpowerStatusKey]
INNER JOIN [DAVE_PL].[dbo].[DimManpower] DimManLM ON DimManpower.[LineManagerKey] = DimManLM.[DimManpowerKey]
INNER JOIN [DAVE_PL].[dbo].[DimManpower] DimManOps ON DimManpower.[OpsManagerKey] = DimManOps.[DimManpowerKey]
INNER JOIN [DAVE_PL].[dbo].[DimInboundTelephony_NaturalKeyType] NaturalKeyType ON Agent_Queue_Day.[DimInboundTelephonyNaturalKeyTypeKey] = NaturalKeyType.[DimInboundTelephonyNaturalKeyTypeKey]
INNER JOIN [DAVE_PL].[dbo].[DimInboundTelephony_CallSource] CallSource ON Agent_Queue_Day.[DimInboundTelephony_CallSourceKey] = CallSource.[DimInboundTelephony_CallSourceKey]
INNER JOIN [DAVE_PL].[dbo].[DimInboundTelephony_CallType] CallType ON Agent_Queue_Day.[DimInboundTelephony_CallTypeKey] = CallType.[DimInboundTelephony_CallTypeKey]
INNER JOIN [DAVE_PL].[dbo].[DimInboundTelephony_CallGroup] CallGroup ON Agent_Queue_Day.[DimInboundTelephony_CallGroupKey] = CallGroup.[DimInboundTelephony_CallGroupKey]
INNER JOIN [DAVE_PL].[dbo].[DimInboundTelephony_SubPL] SubPL ON Agent_Queue_Day.[DimInboundTelephony_SubPLKey] = SubPL.[DimInboundTelephony_SubPLKey]
INNER JOIN [DAVE_PL].[dbo].[DimInboundTelephony_PL] PL ON Agent_Queue_Day.[DimInboundTelephony_PLKey] = PL.[DimInboundTelephony_PLKey]
INNER JOIN [DAVE_PL].[dbo].[DimInboundTelephony_BusinessUnit] BusinessUnit ON Agent_Queue_Day.[DimInboundTelephony_BusinessUnitKey] = BusinessUnit.[DimInboundTelephony_BusinessUnitKey]
INNER JOIN [DAVE_PL].[dbo].[DimInboundTelephony_Switch] Switch ON Agent_Queue_Day.[DimInboundTelephony_SwitchKey] = Switch.[DimInboundTelephony_SwitchKey]
WHERE
[Agent_Queue_Day].[DimDateKey] >= @Tel_StartDate
AND [Agent_Queue_Day].[DimDateKey] <= @Tel_EndDate
AND BusinessUnit.[Name] = 'BGS'
AND DimManpowerDepartment.[DepartmentDescription] IN ('Customer Care','Homemove')
AND DimManpowerSite.[SiteDescription] = 'Uddingston'
AND CallGroup.[Name] IN ('BGS_Retention','BGS_HOMEMOVERS')
AND CallType.[Name] IN ('BGS_RETENTION','BGS_RETENTION_ENGINEER','BGS_RETENTION_JCT','BGS_RETENTION_LANDLORDS','BGS_RETENTION_LEG','BGS_RETENTION_ROCI')
AND DimManpowerStatus.[StatusDescription] <> 'Leaver'
GROUP BY
DimDate.[FullDate],
(DimDate.[FullDate] - (datepart(dw, DimDate.[FullDate])-1)),
DimDate.[ISOYear],
DimDate.[ISOWeekOfYear],
DimSystem.[SystemName],
DimManpower.[BusinessKey],
DimManpower.[FirstName] + ' ' + DimManpower.[LastName],
DimManLM.[FirstName] + ' ' + DimManLM.[LastName],
DimManOps.[FirstName] + ' ' + DimManOps.[LastName],
DimManpowerDepartment.[DepartmentDescription],
DimManpowerSite.[SiteDescription],
DimManpowerActivity.[ActivityDescription],
DimManpowerGrade.[GradeDescription],
DimManpowerStatus.[StatusDescription],
BusinessUnit.[Name],
PL.[Name],
SubPL.[Name],
CallGroup.[Name],
CallType.[Name]
ORDER BY
DimDate.[FullDate],
DimSystem.[SystemName],
DimManpower.[BusinessKey],
BusinessUnit.[Name],
PL.[Name],
SubPL.[Name],
CallGroup.[Name],
CallType.[Name]