zoukankan      html  css  js  c++  java
  • 常用sqlserver 查询DB状态的语句

    1. 查各个表占用空间以及记录数

    select object_name(id) as tablename,8*reserved/1024 as reserved,
    rtrim(8*dpages/1024)+'Mb' as used,8*(reserved-dpages)/1024 as unused,
    8*dpages/1024-rows/1024*minlen/1024 as free, rows from sysindexes
    where indid=1 and object_name(id) like 'dnt%' order by sysindexes.rows desc

    2. 把各个表的所有char/varchar列找出来 

    nchar(type=47 and xtype=239),

    char(type=47 and xtype=175)

    nvarchar(type=39 and xtype=231)

    varchar(type=39 and xtype=167)
    select object_name(id) as tablename, name,
    case xtype
    when 239 then 'nchar'
    when 175 then 'char'
    when 231 then 'nvarchar'
    when 167 then 'varchar'
    end as chartype from sys.syscolumns
    where object_name(id) like 'dnt_%' and ((type=47 and xtype=175)
    or (type=39 and xtype=167))
    order by object_name(id),colorder
      
  • 相关阅读:
    Sass变量、嵌套
    遮罩层2
    遮罩层
    大图轮播
    项目资料(主页)
    关于时间控制和制定时间日期
    dom作业
    js的dom操作和函数
    js数组去重
    js For循环练习。
  • 原文地址:https://www.cnblogs.com/zitjubiz/p/Sqlserver_Stat_query.html
Copyright © 2011-2022 走看看