SQL Server: Tables, Views and missing columns
When it comes to non-schema-bound-views (NSB View) it is important to remember that there is no schema bound between objects used in the view and metadata for a view. Let’s look at the following scenario: — Create Table_1 CREATE TABLE dbo.Table_1 (Col_A int NULL, Col_B numeric(18, 0) NULL, Col_C nvarchar(50) NULL) ON [PRIMARY] GO; — — Add data INSERT dbo.Table_1 (Col_A, Col_B, Col_C) VALUES (10, 10.5, 'ABC'); INSERT dbo.Table_1 (Col_A, Col_B, Col_C) VALUES (20, 0.5, 'DEFG'); — — Create View CREATE view [dbo].[vw_MyView] AS SELECT TBL.*, (TBL.Col_A * TBL.Col_B) AS ColMult FROM dbo.Table_1 TBL GO; An attempt to use the view would give the following result: Col_A, Col_B, Col_C, ColMult ================================= 10, 10.5, ABC, 105 20, 0.5, DEFG, 10 So far Read more