declare @name varchar(1000)
declare @sql varchar(1000) if object_id('tempdb..#space') is not null drop table #space
create table #space(name varchar(50),rows bigint,reserved varchar(12),data varchar(12),index_size varchar(12),unused varchar(12)) declare sp cursor local for select '['+name+']' from sysobjects where type = 'u'
open sp
fetch sp into @name
while @@fetch_status = 0
begin
set @sql = 'insert into #space exec sp_spaceused ' + @name
exec(@sql)
fetch sp into @name
end
close sp select * from #space order by cast(replace(reserved,'kb','')as int) desc

来自:SQL Server技术产品群(250942633)群友

本人独立博客:http://www.haoyuncn.net/sql-server-space

SQL Server 查看数据表占用空间大小的SQL语句的更多相关文章

  1. MySQL数据库查看数据表占用空间大小和记录数

    MySQL数据库中每个表占用的空间.表记录的行数的话,可以打开MySQL的 information_schema 数据库.在该库中有一个 TABLES 表,这个表主要字段分别是: TABLE_SCHE ...

  2. 查看sql server数据库各表占用空间大小

    exec sp_MSForEachTable @precommand=N' create table ##(id int identity,表名 sysname,字段数 int,记录数 int,保留空 ...

  3. Sql Server删除数据表中重复记录 三种方法

    本文介绍了Sql Server数据库中删除数据表中重复记录的方法. [项目]数据库中users表,包含u_name,u_pwd两个字段,其中u_name存在重复项,现在要实现把重复的项删除![分析]1 ...

  4. MS SQL Server中数据表、视图、函数/方法、存储过程是否存在判断及创建

    前言 在操作数据库的时候经常会用到判断数据表.视图.函数/方法.存储过程是否存在,若存在,则需要删除后再重新创建.以下是MS SQL Server中的示例代码. 数据表(Table) 创建数据表的时候 ...

  5. sql server 查看锁表SQL【转】

    1.select * from sys.dm_tran_locks或sp_LOCK 查看request_node 字段中为'X'(排他锁)或'IX'(意向排他锁)2.用sp_who2 + pid(进程 ...

  6. SQL Server 的数据表简单操作

    --创建数据表--[use 要创建数据表的数据库名称go]create table 要创建的表名(字段名 数据类型[长度] [null | not null] [primary key],... .. ...

  7. sql server查看创建表的代码,表定义

    1.查看建表语句在“对象资源管理器”中找到要导出的表,选中该表并单击右键,“编写表脚本为(S)”/“CREATE到(C)”/“新查询编辑器窗口”即可查看该表的建表语句.2.导出建表语句在“对象资源管理 ...

  8. VFP获取 SQL Server 的数据表、触发器、存储过程、视图等脚本

    本文代码转载自红雨先生 *-----------------------------------------------* SqlServer 相关函数*----------------------- ...

  9. Azure 云平台用 SQOOP 将 SQL server 2012 数据表导入 HIVE / HBASE

    My name is Farooq and I am with HDinsight support team here at Microsoft. In this blog I will try to ...

随机推荐

  1. MVC5 Controller简要创建过程(1):ControllerFactory的创建

    即将离职,闲来无事回顾下MVC的源码,到了Controller创建这里,由于流程有点复杂,鉴于自己记性不太好,索性就记录一下吧,方便日后参照. 首先看MvcHandler: public class ...

  2. bootstrap注意事项(四)表格

    1.基本实例 为任意 <table> 标签添加 .table 类可以为其赋予基本的样式 — 少量的内补(padding)和水平方向的分隔线.这种方式看起来很多余!?但是我们觉得,表格元素使 ...

  3. 整理的一些数据库不容易想到的SQL语句实例一

    1.行转列SQL语句 SELECT * FROM ( SELECT [FID] , [Weeks] , [Qty] FROM dbo.TempTable where Weeks is not null ...

  4. bootstrap的导航改造

    在使用bootstrap制作后台时用到了响应式导航条,其中dropdown组件更是用的比较多,用的多需要点击的就多,dropdown默认鼠标左键单击才展开,如果使用鼠标放上去(hover)就展开则会省 ...

  5. doGet与doPost的区别

    转自:http://blog.csdn.net/luoweifu/article/details/7865243   目录(?)[-] 不同点一 不同点二 输入表单inputhtml Serlvlet ...

  6. php curl详解用法[真的详解]

    目前为目最全的CURL中文说明了,学PHP的要好好掌握.有很多的参数.大部份都很有用.真正掌握了它和正 则,一定就是个采集高手了. 通用函数: function curl_file_get_conte ...

  7. Maximum & Minimum Depth of Binary Tree

    Given a binary tree, find its maximum depth. The maximum depth is the number of nodes along the long ...

  8. php 接收curl json 数据

    curl -H "Content-Type: application/json" http://127.0.0.1:8000 -X POST -d 'xxxx' php $strP ...

  9. MySQL数据库mysqlcheck的使用方法

    MySQL数据库mysqlcheck的使用方法的相关知识是本文我们主要要介绍的内容,我们知道,mysqlcheck,是mysql自带的可以检查和修复MyISAM表,并且它还可以优化和分析表,mysql ...

  10. onActivityResult不起作用?可能是和你的launchMode有关!

    昨天在自己的项目中用到了onActivityResult()方法获得activity的返回值.我从Activity01通过 startActivityForResult启动了Activity02和Ac ...