USE [Users_mdb]
GO
IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[AssetTypeAdv]'))
DROP VIEW [dbo].[AssetTypeAdv]
GO
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
IF NOT EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[AssetTypeAdv]'))
EXEC dbo.sp_executesql @statement = N'
CREATE VIEW [dbo].[AssetTypeAdv]
AS
SELECT     A.[nID], A.[tBriefDescription] AS tName, 
	(SELECT tBriefDescription FROM Resources01_Dat.dbo.tblDts WHERE (nID = A.Level_1)) AS Level_1, 
	A.[Has_An_Associated_Cost_], B.tAttachments AS ''tblAttachments_tAttachments'', 
	A.Level_2, A.Track_As, 
	A.Can_Be_Requested, A.Total_Available
FROM         [Resources01_Dat].[dbo].[tblDts] AS A LEFT JOIN [Resources01_Dat].[dbo].[tblAttachments] AS B ON A.[nID]=B.[nID]
WHERE (A.[nUsageType]=2 AND A.[Item_Level]=3 AND A.[tShowInSummary]=''-1'' AND (A.[Visible] = 1 OR A.[Visible] IS NULL))
' 
GO
