create trigger trigger_name
on table_name
for insert,update,delete
as
if (datepart(yy,getdate())%4=0 or datepart(yy,getdate())%100=0)
begin
 if (datepart(hh,getdate()) between '0' and '8')
 or (datepart(hh,getdate()) between '12' and '14')
 or (datepart(hh,getdate()) between '18' and '24')
 or (datepart(dw,getdate()) = '7')
 or (datepart(dw,getdate()) = '1')
 or (datepart(dy,getdate()) between '122' and '128')
 or (datepart(dy,getdate()) between '275' and '281')
 begin
  print'非上班时间,不能插入或修改数据'
  rollback transaction
 end
end
else if(datepart(yy,getdate())%4!=0 or datepart(yy,getdate())%100!=0)
begin
 if (datepart(hh,getdate()) between '0' and '8')
 or (datepart(hh,getdate()) between '12' and '14')
 or (datepart(hh,getdate()) between '18' and '24')
 or (datepart(dw,getdate()) = '7')
 or (datepart(dw,getdate()) = '1')
 or (datepart(dy,getdate()) between '121' and '127')
 or (datepart(dy,getdate()) between '274' and '280')
 begin
  print'非上班时间,不能插入或修改数据'
  rollback transaction
 end
end
drop trigger trigger_name

SQLSERVER中的非工作时间不得插入数据的触发器的实现的更多相关文章

  1. SqlServer中日期和时间数据类型及函数 【转】

    来源:http://blog.csdn.net/royalwzy/article/details/6446075 日期和时间数据类型 下表列出了 Transact-SQL 的日期和时间数据类型. 数据 ...

  2. sqlserver中查找长时间未提交事务

    无论是有意无意,如果事务在数据库中保持打开,则它会阻塞其他进程对修改后的数据进行操作.同样,对事务日志进行备份也只会截断不活动事务的那部分事务日志,所以打开的事务会导致日志变多(甚至达到物理限制),直 ...

  3. SqlServer中的UNION操作符在合并数据时去重的原理以及UNION运算符查询结果默认排序的问题

    本文出处:http://www.cnblogs.com/wy123/p/7884986.html 周围又有人在讨论UNION和UNION ALL,对于UNION和UNION ALL,网上说的最多的就是 ...

  4. C语言中链表任意位置怎么插入数据?然后写入文件中?

    链表插入示意图:(图是个人所画)因为链表指针指来指去,难以理解,所以辅助画图更加方便. 插入某个学号后面图: 定义的结构体: struct student { ]; //学生学号 ]; //学生姓名 ...

  5. hive中创建子表并插入数据过程初始化MR报错解决方法

    本文继成上一篇通过hive分析nginx日志文章,详情参考下面链接: http://www.cnblogs.com/wcwen1990/p/7066230.html 接着来: 创建业务子表: drop ...

  6. shell脚本中向hive动态分区插入数据

    在hive上建表与普通分区表创建方法一样: CREATE TABLE `dwa_m_user_association_circle`( `device_number` string, `oppo_nu ...

  7. oracle中两个时间类型的数据相减默认得到的是天数。

    想要得到月份数,需要使用months_between函数. months_between(to_date('201707','yyyyMM'),to_date('201706','yyyyMM'))  ...

  8. [转]在SqlServer 中解析JSON数据

      在Sqlserver中可以直接处理Xml格式的数据,但因为项目需要所以要保存JSON格式的数据到Sqlserver中在博客:Consuming JSON Strings in SQL Server ...

  9. QStandardItemModel的data线程安全(在插入数据时,临时禁止sizeHint去读model中的data)

    版权声明:本文为博主原创文章,欢迎转载,转载请注明出处 https://blog.csdn.net/MatchYang/article/details/52988257 在直接使用QStandardI ...

随机推荐

  1. 解决“mongoengine.fields.ImproperlyConfigured: PIL library was not found”报错

    解决方案: pip install Pillow

  2. config之安全(用户认证)

    config server 端: 配置账号密码: 那么config client如何连接带有认证的config server呢? 假设两个同时使用,属性的优先级比uri的优先级高.

  3. MongoDB 安装及开启关闭

    开启关闭的方式: 命令行 输入 net start mongodb 就打开mongo的服务了 输入 net stop mongodb 关闭服务 验证是否成功的方式: 在浏览器中输入 http://lo ...

  4. Ansible4:Ad-hoc与命令执行模块

    目录 Ad-hoc 命令说明 后台执行 命令执行模块 command模块 script模块 Ad-Hoc 是指ansible下临时执行的一条命令,并且不需要保存的命令,对于复杂的命令会使用playbo ...

  5. python 启航

    first = 1while first<=9: sec = 1        while sec <= first:        print(  str(sec)+"*&qu ...

  6. Spring Boot的属性加载顺序

        伴随着团队的不断壮大,往往不需要开发人员知道测试或者生产环境的全部配置细节,比如数据库密码,帐号信息等.而是希望由运维或者指定的人员去维护配置信息,那么如果要修改某项配置信息,就不得不去修改项 ...

  7. NO.11天作业

    打印uid在30~40范围内的用户名.awk -F: '$3>=30 && $3<=40{print $1,$3}' /etc/passwd 打印第5-10行的行号和用户名 ...

  8. MapReduce (MRV1)设计理念与基本架构

    MapReduce 是一个分布式计算框架,主要由两部分组成:编程模型和运行时环境. 其中,编程模型为用户提供了非常易用的编程接口,用户只需要像编写串行程序一样实现几个简单的函数即可实现一个分布式程序, ...

  9. [整理]C语言函数说明和定义

    函数的一般形式是:type-specifier function_name(parameter list) parameter declarations{   body of the function ...

  10. CodeForces 816C 思维

    On the way to school, Karen became fixated on the puzzle game on her phone! The game is played as fo ...