Reputation: 377
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'.
Upvotes: 2
Views: 3232
Reputation: 520918
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.
Upvotes: 3