设置写入grant insert,update on 表 to username只能读不能写deny insert, update on 表  to username
grant select on 表 to username

解决方案 »

  1.   

    同意 txlicenhe(马可&不做技术高手) 
    建议使用触发器,你可以在触发器内进行时间判断时间,如果动作类型和时间设定有冲突
    则进行回滚,或者使用Instead Of触发器。
      

  2.   

    create trigger t_test on 表名
    for insert,update,delete
    as
    declare @d varchar(8)
    set @d=convert(varchar(8),getdate(),108)  --取得当前时间
    if @d<'08:30:00' or @d>'17:00:00'       --如果当前时间不在 08:30:00 至 17:00:00 之间,则取消对表的新增/修改/删除操作.
      rollback tran
    go
      

  3.   

    to:zjcxc(邹建) set @d=convert(varchar(8),getdate(),108)  --取得当前时间
    if @d<'08:30:00' or @d>'17:00:00'
    不正确:
    因为他是按字符的顺序排列的。9:01:00 不在8:01:00 和 17:00:00之间.
    应该把它变为时间在排序。
    请看:if (convert(varchar(8),getdate(),108) between '9:01:00' and '17:11:11' )
    print 'yes'
    else print 'no'
    现在时间:9:35
    结果: no
    不合常理
      

  4.   

    我用MFC 的ODBC接口,开发访问SQL Server2000数据库的应用程序,不知道为什么在用记录集打开的数据源的时候,会出现异常错误,他的错误是这样的:当查找的表中有满足条件的记录是,会弹出异常错误,当没有满足条件的记录时,不会报错,会正常弹出表中没有满足条件的记录,代码如下:
    CString szSQL; 
      szSQL.Format("SELECT * FROM %s WHERE BillID = '%s'", m_strTable, m_strBill);
    try{
    RMBillIDRecset rs(&m_RMBillDB);
    if (!rs.Open(CRecordset::snapshot, szSQL) || rs.IsEOF()) { // Invalid binding
    AfxMessageBox("无效的账号。");
      rs.Close();
    return ;
    }
    CString strLuo;
    strLuo = "所查找的帐号为:";
    strLuo += rs.m_BillID;
    strLuo += "\n\r";
    strLuo += "帐号的密码为:";
    strLuo += rs.m_Password;
     
    AfxMessageBox(strLuo);
    rs.Close();
    }
    catch (CDBException *pdb) {
    pdb->Delete();
    AfxMessageBox( "数据库错误,请再试一次。");
    }
      

  5.   

    to: welyngj(平平淡淡) 你没有注意我的时间写法吗?对于9:01:00 ,要写成09:01:00
    if (convert(varchar(8),getdate(),108) between '09:01:00' and '17:11:11' )
    print 'yes'
    else print 'no'结果为"yes"
      

  6.   

    grant insert,update on 表 to usernamedeny insert, update on 表  to username
    grant select on 表 to username