create view syntax(column1, column2, column3)

I’ll be the first person to admit- I’ve ALWAYS been a huge fan of views (instead of sprocs) because they really make things EASIER.

I’ve originally read about the importance of using views 12 years ago when I was playing around with Analysis Services.

I’m starting to finally use this notation- I wish I had start doing this 12 years ago

I just think that naming the columns in the create view statement is more elegant than giving each column an alias.

-Aaron

create view dbo.DWF_INVENTORY_ON_HAND_RealTime
(
[DWF_INVENTORY_ON_HAND_PREFIX]
,[DWF_INVENTORY_ON_HAND_ENTITY_CD]
,[DWF_INVENTORY_ON_HAND_LOCATION_CD]
,[DWF_INVENTORY_ON_HAND_PRODUCT_NUM]
,[DWF_INVENTORY_ON_HAND_ON_HAND_QTY]
,[DWF_INVENTORY_ON_HAND_ON_HAND_VOLUME_QTY]
,[DWF_INVENTORY_ON_HAND_MOVING_AVG_COST_DOL]
,[DWF_INVENTORY_ON_HAND_LAST_COST_DOL]
,[DWF_INVENTORY_ON_HAND_EXTENDED_COST_DOL]
,[DWF_CTRL_DATE_INSERT]

)
As

SELECT ‘SJI’ as Prefix, ENTITY_CD, LOCATION_CD, ITEM_NO, QTY_ON_HAND, VOLUME_ON_HAND, MOVING_AVG_COST, LAST_COST, EXTENDED_COST, GetDate() as InsertDate
FROM DW_Staging_Bluebee.dbo.DWS_BB_INVENTORY_ON_HAND
UNION

SELECT ‘BPB’ as Prefix, ENTITY_CD, LOCATION_CD, ITEM_NO, QTY_ON_HAND, VOLUME_ON_HAND, MOVING_AVG_COST, LAST_COST, EXTENDED_COST, GetDate() as InsertDate
FROM DW_Staging.dbo.DWS_BPB_INVENTORY_ON_HAND_TEMP_LT97