--Common Table Expressions(CTE)
WITH HighSample (SampleId,SampleTitle,SampleContent) AS
(
SELECT SampleId,SampleTitle,SampleContent From CompetitionSample
WHERE SampleId>1
)
SELECT * From HighSample --游标
DECLARE curSample INSENSITIVE CURSOR
FOR SELECT TOP 10 SampleId,SampleTitle,SampleContent FROM CompetitionSample
DECLARE @SampleId int
DECLARE @SampleTitle nvarchar(540)
Declare @SampleContent nvarchar(1000)
Open curSample
FETCH NEXT FROM curSample INTO @SampleId,@SampleTitle,@SampleContent
WHILE @@Fetch_Status=0
BEGIN
PRINT @SampleTitle+','+@SampleContent
Fetch NEXT FROM curSample Into @SampleId,@SampleTitle,@SampleContent
END
CLOSE curSample
DEALLOCATE curSample --N到M条记录(要有主索引ID)
--Select Top M-N * From 表 Where ID in (Select Top M ID From 表) Order by ID Desc
select * from ShoppingCouponsList
Select Top (15-10) * From ShoppingCouponsList Where ShoppingCouponsID in (Select Top 15 ShoppingCouponsID From ShoppingCouponsList) Order by ShoppingCouponsID Desc --触发器(添加,修改)
--text,ntext 无法创建约束,可以用此方法
drop TRIGGER Sample_insert CREATE TRIGGER DuSample_insert
ON CompetitionSample
FOR INSERT,UPDATE AS --常见的触发器有三种:分别应用于Insert , Update , Delete 事件
declare @s nvarchar(500)
set @s='err,geovindu'
IF EXISTS (SELECT * FROM CompetitionSample where charindex('</title>',SampleContent)=1)
begin
ROLLBACK TRANSACTION
RAISERROR('有非法字符',16,1,@s)
end --修改不了
update CompetitionSample set SampleContent='</title>' where SampleId='1'
--添加不了
insert into CompetitionSample(SampleTitle,SampleBrandId,SamplePlatformId,SampleSmallPic,SampleContent,SampleAuthor,SampleIs)
values('d2',1,1,'gif','</title>2','g2',0) select * from CompetitionSample where charindex('</title>',SampleContent)=1

sql: TRIGGER的更多相关文章

  1. use sql trigger call java function

    Use UDF sys_exec to do this. You can use this link to use sys_exec function. It says, sys_exec sys_e ...

  2. SQL Trigger(触发器)

    1.触发器对表进行插入.更新.删除的时候会自动执行的特殊存储过程. 2.触发器一般用在check约束更加复杂的约束上面. 3.触发器和普通的存储过程的区别是:触发器是当对某一个表进行操作. 4.upd ...

  3. 四. sql上线平台

    一.inception安装使用 inception是一个集审核.执行.备份及生成回滚语句于一身的MySQL自动化运维工具 [root@CentOS ~]# [root@CentOS ~]# wget ...

  4. mysql5.5手册读书日记(3)

    <?php /* MySQL_5.5中文参考手册 587开始 与GROUP BY子句同时使用的函数和修改程序 12.10.1. GROUP BY(聚合)函数 12.10.2. GROUP BY修 ...

  5. GoldenGate单向复制配置示例

    一:环境介绍 --source端 ip地址:192.168.123.10 数据库版本:11.2.0.1.0 32 bit 操作系统版本:centos 4.5 32 bit ogg版本:fbo_ggs_ ...

  6. 搭建一个Oracle到Oracle的Goldengate双向复制环境

    目标:搭建一个Oracle到Oracle的Goldengate双向复制环境(支持DDL+DML). 环境: OS:Red Hat Enterprise Linux Server release 5.5 ...

  7. Zero Downtime Upgrade of Oracle 10g to Oracle 11g Using GoldenGate — 3

    DDL Setup Steps SQL> grant execute on utl_file to ggs; Grant succeeded. Create GLOBALS file [orac ...

  8. Deploying Customizations in Oracle E-Business Suite Release 12.2

    DeployingCustomizations in Oracle E-Business Suite Release 12.2 This documentdescribes how to deploy ...

  9. DML_DDL_触发器

    Oracle触发器1-介绍Oracle官方参考:PL/SQL Language Referenc->9 PL/SQL TriggerReasons to Use Trigger:■ Automa ...

随机推荐

  1. chrome cpu占用100%

    参考原文地址:https://stackoverflow.com/questions/20276097/chrome-devtools-100-cpu 问题描述,chrome打开devtools开发者 ...

  2. maven项目报错

    [root@kube-master iff]# kubectl logs iff-dm-3029278244-9qrp6 -n iffjava.lang.IllegalArgumentExceptio ...

  3. CentOS 7 查看和设置防火墙状态

    CentOS7 默认使用的是firewall作为防火墙 查看防火墙状态 firewall-cmd --state 停止firewall systemctl stop firewalld.service ...

  4. ThreadFactory类的使用

    之前创建线程的话,基本上是使用new Thread(),或者是将任务提交到线程池执行.今天看了一下洁城浩的<图解java多线程设计模式>突然看到还可以使用ThreadFactory来创建一 ...

  5. Servlet验证

    一.servlet代码 二.验证 三.总结 在这个servlet验证过程当中,主要是解码方式的运用,特别是输入中文时容易出现乱码.在表单的action中需要输入路径. 四.网盘 链接:https:// ...

  6. Access computer files on iPad without using iTunes.

    going to my CSDN blog ---> https://blog.csdn.net/qq_37746801/article/details/89708103

  7. selenium 之Ran 0 tests in 0.000s

    from selenium import webdriverfrom time import ctime,sleepimport unittestclass TestLogin(unittest.Te ...

  8. 实验Complex

    #include<iostream> #include<cmath> using namespace std; class Complex { public: Complex ...

  9. Mac 下安装mysqldb 问题:一条命令解决mysql_config not found

    遇到过几次pip安装mysql-python的时候出现如题的问题,在这里记录一下解决方法. 找不到mysql_config一般是由于通过lnmp.org或者其他方式安装mysql以后mysql_con ...

  10. 判断弹出框存在(alert_is_ present)

    系统弹窗这个是很常见的场景,有时候它不弹出来去操作的话,会抛异常.那么又不知道它啥时候会出来,那么久需要去判断弹窗是否弹出了 判断 alert 源码分析 class alert_is_present( ...