关键字' read'附近的语法不正确

时间:2015-08-26 03:27:48

标签: sql-server

为什么在关键字' read'?

附近出现错误的语法错误
create view viewJab
as 
    select kojab,nmjabatan
    from jabatan
    with read only;

错误:

  

Msg 156,Level 15,State 1,Procedure viewJab,Line 5
  关键字' read'附近的语法不正确。

2 个答案:

答案 0 :(得分:0)

create view viewJab
with SCHEMABINDING
as select kojab,nmjabatan
from dbo.jabatan

DENY UPDATE ON dbo.viewjab TO username

答案 1 :(得分:0)

使用INSTEAD OF触发器:

创建视图:

create view viewJab as 
select kojab,nmjabatan
from jabatan;

<强> TRIGGER:

CREATE TRIGGER dbo.ViewJab_Trigger_OnInsertOrUpdateOrDelete]
ON dbo.viewJab
INSTEAD OF INSERT, UPDATE, DELETE
AS
BEGIN
        RAISERROR ('You are not allow to update this view!', 16, 1)     
END