USE [test]
GO
/****** Object: StoredProcedure [dbo].[wangchuang] Script Date: 2016/8/25 14:09:24 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
-- =============================================
-- Author: <Author,,Name>
-- Create date: <Create Date,,>
-- Description: <Description,,>
-- =============================================
ALTER PROCEDURE [dbo].[wangchuang] AS
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
declare @strsql varchar()
declare kindcollection cursor --声明游标
for select kind from kind
open kindcollection --打开 declare @noToUpdate varchar() --声明一个变量,用于读取游标中的值
fetch next from kindcollection into @noToUpdate while @@fetch_status= --循环读取 begin
-- print @noToUpdate
-- print GETDATE() set @strsql = 'delete from test.dbo.abc1_'+@noToUpdate+' where endtime< GETDATE()';
print @strsql
execute(@strsql) fetch next from kindcollection into @noToUpdate
end close kindcollection --关闭
deallocate kindcollection --删除
END

SQL作业的更多相关文章

  1. MS SQL作业Schedule的限制注意事项

      最近遇到了一个关于MS SQL作业Schedule下有限制的特殊案例,有一个作业,用户要求执行的时间为:9:30,14:30,16:30, 19:00,于是我设置了两个Schedule,其中一个每 ...

  2. 查看sql 作业明细及运行记录

    --查看作业明细及状态 select j.name 'Job名', j.description '描述', j.ENABLED job_enabled, cast(js.last_run_date a ...

  3. 如何跑通第一个 SQL 作业

    简介: 本文由阿里巴巴技术专家周凯波(宝牛)分享,主要介绍如何跑通第一个SQL. 一.SQL的基本概念 1.SQL 分类 SQL分为四类,分别是数据查询语言(DQL).数据操纵语言(DML).数据定义 ...

  4. SQL作业的操作全

    --定义创建作业 转自http://hi.baidu.com/procedure/blog/item/7f959fb10d76f95d092302dd.html DECLARE @jobid uniq ...

  5. sql 作业+游标 自动备份数据库

    前言 昨天有个同事在客户的服务器上面弄数据库,不小心执行了一条 sql 语句 TRUNCATE TABLE xxx 碉堡了吧,数据全没了  - - ,然后就是在网上拼命的搜索关于数据恢复的软件,搞了一 ...

  6. SQL作业及调度创建

    转自:http://www.cnblogs.com/accumulater/p/6223909.html --定义创建作业 转自http://hi.baidu.com/procedure/blog/i ...

  7. 创建SQL作业错误的解决方法(不能将值 NULL 插入列 'owner_sid',表 'msdb.dbo.sysjobs';列不允许有空值。)

    在用SQL语句创建SQL Server作业时有时出现如下错误: 消息 515,级别 16,状态 2,过程 sp_add_job,第 137 行 不能将值 NULL 插入列 'owner_sid',表  ...

  8. 通过存储过程创建SQL作业

    USE dbNameGO/****** Object: StoredProcedure [dbo].[usp_Createjob] Script Date: 03/26/2014 14:36:30 * ...

  9. 对sql作业的总结(不用group by 通过with as,exists实现分类)

    一次数据库作业 题目如下: Consider the following SQL table definitions: CREATE TABLE OlympicEvent ( Name text, Y ...

  10. 创建sql作业(JOB)

    在SQL Server日常需求处理中,会遇到定时执行或统计数据的需求,这时我们可以通过作业(JOB)来处理,从而通过代理的方式来实现数据的自动处理.一下为SQL Server中创建作业的脚本,供大家参 ...

随机推荐

  1. jQuery操作radio、checkbox、select总结

    1.radio:单选框 HTML代码: <input type="radio" name="radio" id="radio1" va ...

  2. C语言清空输入缓冲区

    来源:http://blog.csdn.net/guanyasu/article/details/53153705 https://zhidao.baidu.com/question/5241738. ...

  3. TCP/IP协议——TCP/IP协议栈及框架

    TCP/IP协议同ISO/OSI模型一样,也可以安排成栈形式.但这个栈不同于ISO/OSI版本,比ISO/OSI栈少,所以又称之为短栈.另外,需要知道的是:TCP/IP协议栈只是许多支持ISO/OSI ...

  4. Tomcat无法访问中文路径的解决办法

    来源于:http://sccassiel.blog.51cto.com/5398709/1141821/ 修改tomcat下的conf/server.xml文件下的 <Connector por ...

  5. ios中xml和html解析(封装)

    下载地址  http://pan.baidu.com/share/link?shareid=2902188921&uk=923776187 GDataXML和TFHpple配置是一样的(配置方 ...

  6. ubuntu 终端中文显示乱码问题!

    1 Alt+Ctrl+F1 进入第一个终端,发现中文乱码. 2 安装zhcon. sudo apt-get install zhcon 3 输入下面命令,启动zhcon,中文显示正常. zhcon - ...

  7. linux shell 脚本攻略学习5---find命令详解

    1.find命令详解 语法: find base_path#base_path可以是任何位置,find会从该位置向下找 实例: amosli@amosli-pc:~$ find /home/amosl ...

  8. React(0.13) 利用componentDidMount 方法设置一个定时器

    <html> <head> <title>hello world React.js</title> <script src="build ...

  9. C# WinForm开发系列 - DataGrid/DataGridView

    在WinForm开发中,DataGrid/DataGridView被广泛使用于绑定数据库中数据进行呈现.整理一些关于DataGrid/DataGridView使用的文章,涉及DataGrid/Data ...

  10. 【Spring】Spring之事务处理

    编程式事务 /** * 1. 根据DataSource去创建事务管理器 * 构造方法 , 参数1. DataSource */ DataSourceTransactionManager txManag ...