USE [Users_mdb]
GO
IF  EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[UserAssets]'))
DROP VIEW [dbo].[UserAssets]
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].[UserAssets]'))
EXEC dbo.sp_executesql @statement = N'CREATE VIEW [dbo].[UserAssets]
AS
SELECT        Users_mdb_tblUser_Submitter.tName AS [Users_mdb_tblUser_Submitter.tName], Users_mdb_tblUser.tName AS [Users_mdb_tblUser.tName], 
                         Users_mdb_tblUser.Security_Type AS [Users_mdb_tblUser.Security_Type], 
                         Resources01_Dat_tblDts.dAssignedTime AS [Resources01_Dat_tblDts.dAssignedTime], 
                         Resources01_Dat_tblDts.dAssignedDate AS [Resources01_Dat_tblDts.dAssignedDate], 
                         Resources01_Dat_tblDts.nUserID AS [Resources01_Dat_tblDts.nUserID], 
                         Resources01_Dat_tblDts.tBriefDescription AS [Resources01_Dat_tblDts.tBriefDescription], 
                         Resources01_Dat_tblDts.Comments AS [Resources01_Dat_tblDts.Comments], 
                         Resources01_Dat_tblDts.Serial_Number AS [Resources01_Dat_tblDts.Serial_Number], Resources01_Dat_tblDts.Model AS [Resources01_Dat_tblDts.Model], 
                         Resources01_Dat_tblDts.Asset_Tag AS [Resources01_Dat_tblDts.Asset_Tag], Resources01_Dat_tblDts.Visible AS [Resources01_Dat_tblDts.Visible], 
                         Resources01_Dat_tblDts.Allocated_to_Department AS [Resources01_Dat_tblDts.Allocated_to_Department], 
                         Resources01_Dat_tblDts.Allocated_to_Unit_Division AS [Resources01_Dat_tblDts.Allocated_to_Unit_Division], 
                         Resources01_Dat_tblDts.Allocated_to_Project AS [Resources01_Dat_tblDts.Allocated_to_Project], 
                         Resources01_Dat_tblDts.Requested_Until AS [Resources01_Dat_tblDts.Requested_Until], 
                         Resources01_Dat_tblDts.Level_1 AS [Resources01_Dat_tblDts.Level_1], Resources01_Dat_tblDts.Level_2 AS [Resources01_Dat_tblDts.Level_2], 
                         Resources01_Dat_tblDts.Version AS [Resources01_Dat_tblDts.Version], 
                         Resources01_Dat_tblDts.mDetailedDescription AS [Resources01_Dat_tblDts.mDetailedDescription], 
                         Users_mdb_tblUser.tEmailName AS [Users_mdb_tblUser.tEmailName], Users_mdb_tblUser.tWorkPhone AS [Users_mdb_tblUser.tWorkPhone], 
                         Users_mdb_tblUser.First_Name AS [Users_mdb_tblUser.First_Name], Users_mdb_tblUser.Last_Name AS [Users_mdb_tblUser.Last_Name], 
                         Users_mdb_tblUser.Roles AS [Users_mdb_tblUser.Roles], Users_mdb_tblUser.Employee_ID AS [Users_mdb_tblUser.Employee_ID], 
                         Users_mdb_tblUser.tUserName AS [Users_mdb_tblUser.tUserName], 
                         UsersMDB_tblDisplayPicAttachment.tAttachments AS [UsersMDB_tblDisplayPicAttachment.tAttachments], 
                         Users_mdb_AssetType.tName AS Users_mdb_AssetType, Users_mdb_Department.tName AS Users_mdb_Department, 
                         Users_mdb_JobTitle.tName AS Users_mdb_JobTitle, Resources02_Def_tblAssetSubStatus.tName AS Resources02_Def_tblAssetSubStatus, 
                         Users_mdb_Location.tName AS Users_mdb_Location, Users_mdb_AssetClass.tName AS Users_mdb_AssetClass, 
                         Users_mdb_tblUser.nID AS [Users_mdb_tblUser.nID]
FROM            dbo.tblUser AS Users_mdb_tblUser LEFT OUTER JOIN
                         dbo.tblDisplayPicAttachment AS UsersMDB_tblDisplayPicAttachment ON 
                         Users_mdb_tblUser.nID = UsersMDB_tblDisplayPicAttachment.nID LEFT OUTER JOIN
                         dbo.Department AS Users_mdb_Department ON Users_mdb_tblUser.Department = Users_mdb_Department.nID LEFT OUTER JOIN
                         dbo.Location AS Users_mdb_Location ON Users_mdb_tblUser.Location = Users_mdb_Location.nID LEFT OUTER JOIN
                         dbo.JobTitle AS Users_mdb_JobTitle ON Users_mdb_tblUser.Job_Title = Users_mdb_JobTitle.nID LEFT OUTER JOIN
                         Resources01_Dat.dbo.tblDts AS Resources01_Dat_tblDts ON Users_mdb_tblUser.nID = Resources01_Dat_tblDts.nUserID LEFT OUTER JOIN
                         dbo.AssetClass AS Users_mdb_AssetClass ON Resources01_Dat_tblDts.Level_1 = Users_mdb_AssetClass.nID LEFT OUTER JOIN
                         dbo.AssetType AS Users_mdb_AssetType ON Resources01_Dat_tblDts.Level_2 = Users_mdb_AssetType.nID LEFT OUTER JOIN
                         Resources02_Def.dbo.tblAssetSubStatus AS Resources02_Def_tblAssetSubStatus ON 
                         Resources01_Dat_tblDts.Asset_Sub_status = Resources02_Def_tblAssetSubStatus.nID LEFT OUTER JOIN
                         dbo.tblUser AS Users_mdb_tblUser_Submitter ON Users_mdb_tblUser_Submitter.nID = Resources01_Dat_tblDts.nSubmitterID
' 
GO
