This issue was resolved by scripting the view as a create, dropping the view, and then recreating the view using the script, so obviously nothing was wrong with the view, per se. However, I am very curious as to what the cause could be...
I have a created like this:
CREATE VIEW [dbo].[Employees_V]
AS
SELECT cast(right(EmployeeNo,4) as int) as EmployeeID
,*
,cast(0 as bit) AS [IsTerritoryManager]
,cast(0 as bit) AS [IsCoordinator]
FROM AD.dbo.ADEmployees_V
The AD.dbo.ADEmployees_V
has a lot of different fields, but the relevant fields are Status
and ISStatus
, defined in the creation of the view as:
,CASE WHEN c.[Status] = 'Active' THEN 'Active' ELSE 'Terminated' END AS [Status]
,CASE WHEN c.[Status] = 'Active' OR ad.[AccountStatus] LIKE '%Enabled%' THEN 'Active' ELSE 'Terminated' END AS [ISStatus]
Today, I added the ISStatus
column to AD.dbo.ADEmployees_V
(Status
was there previously).
After making that change, I did a:
SELECT * FROM [Employees_V]
Surprisingly, this did not return the proper results. ISStatus
did not appear as a column header, and instead of being populated with 0s, IsTerritoryManager
was populated with the new ISStatus
values!
I am guessing that this is some sort of caching issue, but I would love an explanation of what is going on under the covers. Thanks!