IF EXISTS(SELECT 1 FROM sys.views WHERE Name = 'quotes_vQuoteBuyoutItems')
DROP VIEW [dbo].[quotes_vQuoteBuyoutItems]
GO

CREATE VIEW [dbo].[quotes_vQuoteBuyoutItems]
AS
SELECT        
	buyoutItem.isActive,
	buyoutItem.itemID,
	buyoutItem.ParentSurfaceItemId,
	buyoutItem.QuoteBuyoutItems_QuoteBuyoutItems_PartsMasterPartNumber,
	buyoutItem.QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsBrand,
	buyoutItem.QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsCondition,
	buyoutItem.QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsCostPriceForex,
	buyoutItem.QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsCostPriceZAR,
	buyoutItem.QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsDescription,
	buyoutItem.QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsDiscount,
	buyoutItem.QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsDutyCost,
	buyoutItem.QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsFreightCost,
	buyoutItem.QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsLeadtime,
	buyoutItem.QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsPartNumber,
	buyoutItem.QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsQuantityAvailable,
	buyoutItem.QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsQuantityRequired,
	buyoutItem.QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsSelected,
	buyoutItem.QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsSequence,
	buyoutItem.QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsTotalCost,
	buyoutItem.QuoteBuyoutItems_QuoteBuyoutItems_QuoteBuyoutItemsWeightKG,
	buyoutItem.recId,
	buyoutItem.surfaceId,
	CreatedBy = item.createdBy,
	CreatedDate = item.dateCreated,
	UpdatedDate = item.dateUpdated,
	UpdatedBy = item.updatedBy
FROM            
	dbo.publ_QuoteBuyoutItems AS buyoutItem LEFT OUTER JOIN
	dbo.pal_SurfaceItem AS item ON buyoutItem.itemID = item.recId 
WHERE        
	(buyoutItem.isActive = 1)
GO


