Chevo1
Chevo1

Reputation: 15

Creating a view: error MSG 156, Level 15, State 1

CREATE VIEW titles_borrowed
AS 
    SELECT b.booktitle, o.bookid
    FROM books b 
    INNER JOIN o borrowed ON b.bookid = o.bookid 

I'm getting the following error when I try to run this:

Msg 208, Level 16, State 1, Procedure titles_borrowed, Line 4 [Batch Start Line 5]
Invalid object name 'o'

Upvotes: 0

Views: 76

Answers (1)

Alrik
Alrik

Reputation: 100

You need to switch o and borrowed:

CREATE VIEW titles_borrowed
AS SELECT b.booktitle,o.bookid
FROM books b 
INNER JOIN borrowed o 
ON b.bookid = o.bookid

First the table then the alias.

Upvotes: 1

Related Questions