基本上就是标题所说的。这是我的代码。
INNER JOIN raceType ON race.raceType = raceType.id INNER JOIN course ON race.course = course.id INNER JOIN team ON race.team = team.id LEFT OUTER JOIN player AS mvp ON race.mvp = mvp.id LEFT OUTER JOIN player AS obs ON race.observer = obs.id; GO SELECT * FROM playerView SELECT * FROM raceView /* Additional Information: The views are very convenient replacements for the tables they represent, as they include the names and calculated values that you will often need in queries. You are very much encouraged to use the views to simplify the queries that follow. You can use a view in a SELECT statement in exactly the same way as you can use a table. If you wish to create additional views to simplify the queries which follow, include them in this file. */
当我分别运行每个文件时CREATE VIEW,似乎可以正确运行且没有错误。但是当我尝试运行整个脚本时,它给了我这个错误。
CREATE VIEW
消息111,级别15,状态1,第20行 “ CREATE VIEW”必须是查询批处理中的第一条语句。 消息111,级别15,状态1,第15行 “ CREATE VIEW”必须是查询批处理中的第一条语句。 消息208,级别16,状态1,第2行 无效的对象名称“ playerView”。
在尝试运行此脚本之前,我首先删除数据库,重新创建表,填充它们,然后运行此脚本。
有什么想法我要去哪里吗?
放在GO后面PRINT 'Creating Player View',它应该可以工作:
GO
PRINT 'Creating Player View'
PRINT 'Creating Player View' GO CREATE VIEW playerView AS