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;
  • 相关阅读:
    《分布式系统关注点——数据一致性(上篇)》阅读笔记
    2.23寒假学习记录
    2.22寒假学习记录
    2.21寒假学习记录
    2.20寒假学习记录
    2.19寒假学习记录
    2.18寒假学习记录
    2.17寒假学习记录
    2.17周一毕设改进计划
    2.16寒假学习记录
  • 原文地址:https://www.cnblogs.com/xbj-hyml/p/3296380.html
Copyright © 2011-2022 走看看