简体   繁体   中英

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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