2

Why do I get Incorrect syntax near the keyword 'or'?

create or replace view view_jab
as select * from jabatan
where kojab = 3
with check option constraint viewJab_ck

Msg 156, Level 15, State 1, Line 2 Incorrect syntax near the keyword 'or'.

Msg 102, Level 15, State 1, Line 5 Incorrect syntax near 'with'.

LJNielsenDk
  • 1,414
  • 1
  • 16
  • 32
rojib
  • 347
  • 1
  • 9
  • 15

1 Answers1

3

You can drop the view if it already exists, and then create it afterwards.

IF OBJECT_ID('view_jab') IS NOT NULL
BEGIN
    DROP VIEW view_jab
END

CREATE VIEW view_jab
AS
SELECT * FROM jabatan
WHERE kojab = 3
WITH CHECK OPTION

Note that I removed the CONSTRAINT from your view, because AFAIK a view cannot have any integrity constraints on it. Please read here and here for more information.

Community
  • 1
  • 1
Tim Biegeleisen
  • 502,043
  • 27
  • 286
  • 360