-1

I'm trying to create a VIEW in my database, and it shows me

"Incorrent syntax error"

Am I doing something wrong?

3
  • 1
    CREATE VIEW must be the only statement in the batch. (Which would be the error if you hover your mouse over the red squiggly line) Commented Apr 20, 2020 at 13:06
  • Please do not post code as images. See here for more details why: meta.stackoverflow.com/questions/285551 Commented Apr 20, 2020 at 13:22
  • Does this answer your question? CREATE VIEW must be the only statement in the batch Commented Apr 20, 2020 at 13:22

2 Answers 2

2

Include GO between your Create View and Select query (or) view should be the only statement.

CREATE  VIEW  [dbo].[View_name]  As

-- view logic

GO


Select * from table
Sign up to request clarification or add additional context in comments.

Comments

2

You selected two select statements. You should run only statement starting from Create View till where clause.

create view view_name as select id from tab where id = some_id;

Just run one statement of create view that's it.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.