I have an sql server view which I've recently added a field to the underlying table and the view itself. I can open the view just fine on the server, but when I try to run it in SQL management Studio on my PC, I get the following error:
> Msg 7352, Level 16, State 1, Line 2
> OLE DB provider 'SQLOLEDB' supplied inconsistent metadata. The
> object
> '[AVANTISERVER\NCL_MASTER].[Avanti].[dbo].[EmployeeFile]'
> was missing expected column 'Code'.
Code is not the column that was added, in fact the added column isn't even on that table.
And Here is the view:
ALTER VIEW [dbo].[WorkOrdersDetailed]
AS
SELECT m.Serial,
m.Description,
m.Make,
m.Model,
m.Notes,
wo.WorkOrderID,
wo.DueDate,
dbo.DateOnly(wo.DueDate) AS [Due Date],
ISNULL(wo.AssignedTo, '') AS AssignedTo,
wo.WorkTypeID,
wo.Completed,
wo.DateCompleted,
wo.CompletedBy,
wo.Manager,
wo.FollowUpBy,
wo.FollowUpDate,
wt.Category,
wt.Description AS WorkType,
REPLACE(wt.Notes, '\r\n', '<br />') AS WorkTypeNotes,
wt.Duration,
CASE wt.Frequency
WHEN '0' THEN 'None'
WHEN '1' THEN 'Daily'
WHEN '7' THEN 'Weekly'
WHEN '28' THEN 'Monthly'
WHEN '56' THEN 'Bi-Monthly'
WHEN '84' THEN 'Quarterly'
WHEN '168' THEN 'Semi-Annually'
WHEN '365' THEN 'Annually'
ELSE 'None'
END AS Frequency,
wo.CompletionNotes,
wo.CreatedBy,
wo.DateCreated,
wt.Status,
CASE Priority
WHEN '1' THEN '1-Highest'
WHEN '2' THEN '2-High'
WHEN '3' THEN '3-Normal'
WHEN '4' THEN '4-Below Normal'
WHEN '5' THEN '5-Lowest'
ELSE 'None'
END AS Priority,
CASE dbo.Departments.DepartmentName
WHEN 'Information Technology' THEN 'I.T.'
ELSE dbo.Departments.DepartmentName + ' - ' + dbo.CostCenter.CenterName
END AS Location,
wo.ToolsReconciled,
wo.PartsReconciled,
wo.CleanReconciled,
wo.TurnedOverTo + ' - ' + dbo.AvantiEmployeeData.LongName AS TurnedOverTo,
wo.TempRepair
FROM dbo.WorkType wt
JOIN dbo.WorkOrders wo ON wo.worktypeid = wo.worktypeid
JOIN dbo.Machines m ON m.serial = wo.machineserial
JOIN dbo.CostCenter cc ON cc.costcenterid = m.costcenter
LEFT JOIN dbo.Departments d ON d.departmentid = cc.department
LEFT JOIN dbo.AvantiEmployeeData aed ON aed.code = wo.turnedoverto
How can I correct this so the error does not happen?