zoukankan      html  css  js  c++  java
  • sql2000 中 存储过程 相关

    1、一个begin..end与多个的区别

      多个 + exception 操作可以更好的、更详细的 捕捉到 sql语句的异常

    2、如果需要创建 随SQL server服务 自启动的存储过程需要注意:

      必需由管理员在master表中创建 or 使用语句 exec sp_procoption '存储过程名','startup','on' 将存储过程设置为自启动

    ====================================================================================

    3、存储过程中 使用 临时表

    --临时表 存储需要处理的 表 ID
        if object_id('#tempObjectIDAA') is not null
            drop table #tempObjectIDAA
        go
        create table #tempObjectIDAA(
            ID                    int  identity(1,1),
            object_id            int,        --表 ID
            avg_fragmentation    decimal        --碎片百分比 * 100
        )
    --正确。向临时表中插入数据
        insert into #tempObjectIDAA(object_id,avg_fragmentation) select object_id,avg_fragmentation_in_percent from sys.dm_db_index_physical_stats (@db_id,null,null,null,'LIMITED') where avg_fragmentation_in_percent >10 and fragment_count > 10 --and index_id > 0;
    --错误。因为这种语法,会新建一个表
        --select object_id,avg_fragmentation_in_percent into #tempObjectIDAA from sys.dm_db_index_physical_stats (@db_id,null,null,null,'LIMITED') where avg_fragmentation_in_percent >10 and fragment_count > 10 and index_id > 0;
  • 相关阅读:
    基于XML的声明式事务控制
    spring中JdbcTemplate使用
    四种常用的通知类型(xml)
    AOP配置步骤(XML)
    12388. 图论割边
    12389. 割点
    12206. 电缆网络
    12178. 破坏牛棚
    java反射笔记
    java单元测试
  • 原文地址:https://www.cnblogs.com/xbj-hyml/p/3296380.html
Copyright © 2011-2022 走看看