question

askmlx121 avatar image
askmlx121 asked

View and views resultset is different????

hi I have created one view that name is testview as shown below create view [dbo].[testview] AS SELECT C.*, CASE WHEN H.AccountID IS NULL THEN 0 ELSE 1 END IsHosted FROM testAccount C LEFT JOIN Accountdetails H ON C.AccountiD = H.AccountID WHERE StateCode = 0 my problem is **ishosted** column of the view. it should be 1 or 0 only return. but when i select the view like below select * from dbo.testview it gives some varchar data like 'active', 'deactive' etc. value in 'ishosted' column why is this unexpected data comes when i select view?
view
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
askmlx121 avatar image
askmlx121 answered
**EXECUTE sp_refreshview N'testview ';** Updates the metadata for the specified non-schema-bound view. Persistent metadata for a view can become outdated because of changes to the underlying objects upon which the view depends. it solves the problem to me........ thanking you for sharing this info....................
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.