SQL判断视图是否存在并创建视图

USE [ZBiddingDB]
GO

/****** Object:  View [dbo].[VWinbidInfoBrowse]    Script Date: 2018/6/20 11:46:12 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO
IF  EXISTS (SELECT * FROM sysobjects WHERE name = N'VWinbidInfoBrowse')
	DROP VIEW  VWinbidInfoBrowse
GO

	CREATE VIEW [dbo].[VWinbidInfoBrowse] AS

	SELECT A.WIID,B.ProjectName,C.ProjectLegalPerson,F.SName,I.COSName AS ConstructionCompanyName,J.COSName AS WinbidCompanyName,A.ProjectId,A.SSID,A.ConstructionCompanyID,A.WinbidCompanyID,
			A.Budget,A.ProjectManager ,A.PMQCNumber,A.PMQCLevel,A.Rate,A.QualityStandard ,A.WinbidDuration ,A.WinbidContent ,A.IsDelete ,A.DeleteRemark ,
			A.CreatorAccountID ,A.CreatorName ,A.CreateDate ,A.LastEditAccountID ,A.LastEditDate, A.NegotiateTime,NegotiateAddress
	FROM TWinbidInfo A
	INNER JOIN CCMPDB.dbo.TProject AS B ON A.ProjectId = B.ProjectID   
	INNER JOIN CCMPDB.dbo.TProjectInfo AS C ON A.ProjectId =C.ProjectID
	INNER JOIN ZBiddingDB.dbo.TSection AS F ON A.SSID = F.SSID
	INNER JOIN KnowledgeDB.DBO.TCustomerOrSupplier AS I ON A.ConstructionCompanyID = I.COSID 
	INNER JOIN KnowledgeDB.DBO.TCustomerOrSupplier AS J ON A.WinbidCompanyID = J.COSID  AND A.IsDelete='0'
GO

你可能感兴趣的:(sql)