0

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

"Incorrent syntax error"

Am I doing something wrong?

Ilyes
  • 14,640
  • 4
  • 29
  • 55
OnlyForFun
  • 43
  • 5
  • 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) – HoneyBadger Apr 20 '20 at 13:06
  • Please do **not** post code as images. See here for more details why: http://meta.stackoverflow.com/questions/285551 –  Apr 20 '20 at 13:22
  • Does this answer your question? [CREATE VIEW must be the only statement in the batch](https://stackoverflow.com/questions/27272194/create-view-must-be-the-only-statement-in-the-batch) – Ilyes Apr 20 '20 at 13:22

2 Answers2

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.

Pankaj_Dwivedi
  • 565
  • 4
  • 15
1

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
karthik kasubha
  • 392
  • 2
  • 13