Tony
Tony

Reputation: 2533

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

Upvotes: 0

Views: 1371

Answers (1)

souLTower
souLTower

Reputation: 181

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

use tempdb
GO
exec sp_spaceused #tmpdata

Upvotes: 4

Related Questions