
PRINT 'EXECUTE 026'

if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[v_mclBook_bibliography]') and OBJECTPROPERTY(id, N'IsView') = 1)
drop view [dbo].[v_mclBook_bibliography]
GO


CREATE VIEW dbo.v_mclBook_bibliography 
AS
SELECT    
	TOP 100 PERCENT 

	dbo.Reference.RefId, 
	dbo.Reference.IdInMCL, 
	dbo.Reference.IsMCLBaseFlora,
	dbo.Reference.IsMCLFlora, 
	dbo.RefCategory.RefCategoryId, 
	dbo.RefCategory.RefCategory, 
	Reference_1.RefId AS InRefId, 
	RefCategory_1.RefCategoryId AS InRefCategoryId, 
	RefCategory_1.RefCategory AS InRefCategory, 
	Reference_1.RefAuthorString AS InRefAuthorString, 
	Reference_1.Title AS InTitle, 
	Reference_1.NomTitleAbbrev AS InNomTitleAbbrev, 
	Reference_1.Volume AS InVolume, 
	Reference_1.Series AS InSeries,
	Reference_1.Edition AS InEdition,
	Reference_1.PublicationTown AS InPublicationTown, 
	Reference_1.RefYear AS InRefYear, 
	Reference_1.PageString AS InPageString, 
	dbo.Reference.RefAuthorString, 
	dbo.Reference.Title, 
	dbo.Reference.Volume, 
	dbo.Reference.Series,
	dbo.Reference.Edition,
	dbo.Reference.PublicationTown, 
	dbo.Reference.RefYear, 
	dbo.Reference.IsPaper, 
	dbo.Reference.URL,
	dbo.Reference.PageString, 
	dbo.Reference.Notes, 
	dbo.Reference.RefCache,
	dbo.Reference.MCLAdditionalSortIndex
FROM         
	dbo.Reference Reference_1 RIGHT OUTER JOIN
        dbo.RefCategory RefCategory_1 ON Reference_1.RefCategoryFk = RefCategory_1.RefCategoryId RIGHT OUTER JOIN
        dbo.Reference INNER JOIN
        dbo.RefCategory ON dbo.Reference.RefCategoryFk = dbo.RefCategory.RefCategoryId ON Reference_1.RefId = dbo.Reference.InRefFk
WHERE     
	(dbo.Reference.IsMCLFlora = 1)
ORDER BY 
	CAST(dbo.Reference.IdInMCL AS INT)
GO


