如果我们的语句为:
IF NOT EXISTS(SELECT 1 FROM sys.views WHERE)BEGINcreate view Report_IndividualTicketasSELECT Ticket.TicketNumber, Ticket.TicketID,GisProcess.StageName,Content.DtReceived, Content.ContentTextFROM(GisProcess INNER JOIN TicketON GisProcess.TicketID=Ticket.TicketID)INNER JOIN ContentON Ticket.ContentID=Content.ContentIDEND
会提示以下错误:
Msg 156, Level 15, State 1, Line 4
Incorrect syntax near the keyword 'view'.
出现这个错误的原因是:create view 这一句必须是批处理中的第一句。
所以可以将该语句修改为:
IF EXISTS(SELECT 1 FROM sys.views WHERE)DROP VIEW Report_IndividualTicketGOcreate view Report_IndividualTicketasSELECT Ticket.TicketNumber, Ticket.TicketID,GisProcess.StageName,Content.DtReceived, Content.ContentTextFROM(GisProcess INNER JOIN TicketON GisProcess.TicketID=Ticket.TicketID)INNER JOIN ContentON Ticket.ContentID=Content.ContentIDGO
新闻热点
疑难解答