SET QUOTED_IDENTIFIER ON

go

/* 创建新视图。                                                                                     */
/* 创建视图 fpf_department。                                                                       */

CREATE VIEW [dbo].[fpf_department] (deptid,deptcode,deptname,type,level,parentid,
			isdelete,schooldeptid,modifieddate ) AS
 	select '000000000001','000000000001', unitName, 1,0,0,-1,0,1
	from unitInfo




go

/* 创建视图 fpf_employee。                                                                         */
CREATE VIEW [dbo].[fpf_employee]
AS
SELECT     NULL AS employeeid, NULL AS employeecode, NULL AS employeename, NULL AS sex, '2000-9-1' AS birthday, NULL AS deptid, NULL 
                      AS schooldeptid, NULL AS isdelete, '2000-9-1' AS modifieddate, NULL AS nation, NULL AS state, NULL AS caegory, NULL AS curlive




go

/* 创建视图 fpf_user。                                                                             */

CREATE VIEW [dbo].[fpf_user]
AS
SELECT     pkId AS id, userName AS loginname, password, fullName AS nickname, email, '1' AS type, '000000000001' AS deptid, - 1 AS isdelete, 
                      1 AS modifieddate, examine AS isactive, examine AS islock, NULL AS employeeid, NULL AS activer, '2000-9-1' AS activedate
FROM         dbo.Users
WHERE     (userName <> 'default') AND (userName <> 'admin')




go




--创建v_news视图
IF EXISTS(SELECT 1 FROM sys.views WHERE name='v_news')
DROP VIEW v_news
GO
CREATE VIEW v_news
AS
SELECT     dbo.news.pkId, dbo.news.intactTitle, dbo.news.useListTitle, dbo.news.passed, dbo.news.updateTime, dbo.news.listTitle, dbo.news.gradeId, dbo.news.gate, 
                      dbo.news.isTop, dbo.news.usersId, dbo.news.bigClassId, dbo.news.Priority, dbo.news.click, dbo.Users.userName, dbo.Users.fullName, dbo.news.validDays, 
                      dbo.news.updateIp, dbo.news.isStatic, dbo.news.staticUrl, dbo.news.isDuplicated, dbo.news.isRecommand, dbo.news.MenuId, dbo.news.AuditUserID, 
                      dbo.news.albumId, dbo.news.imageName, dbo.news.copyfrom
FROM         dbo.news INNER JOIN
                      dbo.Users ON dbo.news.usersId = dbo.Users.pkId
GO
