简体   繁体   English

SQL Server-如何计算数据库中每个表的某些行的大小?

[英]Sql Server - How to calculate the size of some rows from each table in a database?

How can i calculate the size of only some rows for each table? 如何计算每个表的某些行的大小?

For example, with the code: 例如,使用代码:

EXEC sp_spaceused 'myTable'

you obtain the size of all rows, however i want to calculate the size not of one single table, but all of them, and using the same clause for each one, something like this in pseudo-code: 您获得了所有行的大小,但是我想计算的不是一个表的大小,而是所有表的大小,并对每个表使用相同的子句,在伪代码中是这样的:

foreach(Table myTable in Database)
  EXEC sp_spaceused 'myTable WHERE AppId='abc''

How can i achieve this with T-SQL? 如何使用T-SQL做到这一点?

Thanks in advance 提前致谢

EDIT: for better clarification 编辑:为了更好的说明

-- Plop the data into a temp table
Select myFields into #tmpdata from myTable where myCondition = 'foo'

use tempdb
GO
exec sp_spaceused #tmpdata

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM