SQLSERVER中的非工作时间不得插入数据的触发器的实现
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
SQLSERVER中的非工作时间不得插入数据的触发器的实现的更多相关文章
- SqlServer中日期和时间数据类型及函数 【转】
来源:http://blog.csdn.net/royalwzy/article/details/6446075 日期和时间数据类型 下表列出了 Transact-SQL 的日期和时间数据类型. 数据 ...
- sqlserver中查找长时间未提交事务
无论是有意无意,如果事务在数据库中保持打开,则它会阻塞其他进程对修改后的数据进行操作.同样,对事务日志进行备份也只会截断不活动事务的那部分事务日志,所以打开的事务会导致日志变多(甚至达到物理限制),直 ...
- SqlServer中的UNION操作符在合并数据时去重的原理以及UNION运算符查询结果默认排序的问题
本文出处:http://www.cnblogs.com/wy123/p/7884986.html 周围又有人在讨论UNION和UNION ALL,对于UNION和UNION ALL,网上说的最多的就是 ...
- C语言中链表任意位置怎么插入数据?然后写入文件中?
链表插入示意图:(图是个人所画)因为链表指针指来指去,难以理解,所以辅助画图更加方便. 插入某个学号后面图: 定义的结构体: struct student { ]; //学生学号 ]; //学生姓名 ...
- hive中创建子表并插入数据过程初始化MR报错解决方法
本文继成上一篇通过hive分析nginx日志文章,详情参考下面链接: http://www.cnblogs.com/wcwen1990/p/7066230.html 接着来: 创建业务子表: drop ...
- shell脚本中向hive动态分区插入数据
在hive上建表与普通分区表创建方法一样: CREATE TABLE `dwa_m_user_association_circle`( `device_number` string, `oppo_nu ...
- oracle中两个时间类型的数据相减默认得到的是天数。
想要得到月份数,需要使用months_between函数. months_between(to_date('201707','yyyyMM'),to_date('201706','yyyyMM')) ...
- [转]在SqlServer 中解析JSON数据
在Sqlserver中可以直接处理Xml格式的数据,但因为项目需要所以要保存JSON格式的数据到Sqlserver中在博客:Consuming JSON Strings in SQL Server ...
- QStandardItemModel的data线程安全(在插入数据时,临时禁止sizeHint去读model中的data)
版权声明:本文为博主原创文章,欢迎转载,转载请注明出处 https://blog.csdn.net/MatchYang/article/details/52988257 在直接使用QStandardI ...
随机推荐
- 在eclipse中安装 Activiti Designer插件
转: Activiti系列——如何在eclipse中安装 Activiti Designer插件 这两天在评估jbpm和Activiti,需要安装一个Activiti Designer插件试用一下. ...
- 通过ORM模型看python对象创建过程
简易django ORM模型如下所示: #!/usr/bin/env python # encoding: utf-8 """ @version: 1.0 @author ...
- 疯狂Android讲义
1 Android应用和开发环境2 Android应用的界面编程3 Android的事件处理4 Activity Fragment5 Intent IntentFilter6 Android应用的资源 ...
- Sensor信号输出YUV、RGB、RAW DATA、JPEG 4种方式区别
简单来说,YUV: luma (Y) + chroma (UV) 格式, 一般情况下sensor支持YUV422格式,即数据格式是按Y-U-Y-V次序输出的RGB: 传统的红绿蓝格式,比如RGB565 ...
- bzoj千题计划136:bzoj3931: [CQOI2015]网络吞吐量
http://www.lydsy.com/JudgeOnline/problem.php?id=3931 在最短路网络上跑最大流 #include<queue> #include<c ...
- bzoj千题计划117:bzoj1026: [SCOI2009]windy数
http://www.lydsy.com/JudgeOnline/problem.php?id=1026 数位DP 如果前一位填的是0, 0是前导0,下一位可以随便填 0不是前导0,下一位不能填1 为 ...
- idea插件安装的通用操作
序:今天下午看到一个bug,很神奇,粘出来大家看看 看到这个异常栈,有经验的或者查到的答案都是mapper.xml中哪个的方法配置错了,应替换parameterMap为parameterType, 奇 ...
- 同一条sql语句,只是改变了搜索的条件,就很慢?
重建索引: ) 显示索引信息: dbcc showcontig('表名’) 具体参考:http://www.cnblogs.com/bluedy1229/p/3227167.html
- 英雄无敌3开源引擎vcmi的编译安装
TAGS: Heroes3, vcmi, opensourceDATE: 2013-08-23 vcmi是什么? vcmi 是经典的 SLG 英雄无敌3 的开源游戏引擎.原来的英雄无敌3只能在Wind ...
- LintCode 387: Smallest Difference
LintCode 387: Smallest Difference 题目描述 给定两个整数数组(第一个是数组A,第二个是数组B),在数组A中取A[i],数组B中取B[j],A[i]和B[j]两者的差越 ...