Unless you are hosting your site on your own server(s), your hosting company will impose a limit on your disk space. Occasionally, you will see a posting in the DotNetNuke forums asking "Why is the database so big?" or "What table is using all the disk space"
So there is two ways to look at this ... via SQL Servier Management Studio (SSMS) or via SQL ... some hosting environments do not allow access via SSMS, so SQL is the only option.
The following SQL will display all the tables:
EXECUTE sp_MSforeachtable 'EXECUTE sp_spaceused [?]'
This statement uses the "hidden" Microsoft store procedure "sp_MSforerachtable" that will execute a given command against each table in a database. You will need to review the results to determine the largest table.
Alternatively, the following T-SQL will generate a list of tables in largest row count to smallest.
set nocount on
-- create table to hold name and rows
-- cannot use in-memory as it will not work with sp_MSforeachtable
Create table #dnntables (
tablename varchar(64),
tablerows int
)
declare @rows int
declare @sql varchar(1000)
-- load table with names
-- undocumented MS stored proc -- well documented on Google
exec sp_MSforeachtable 'insert into #dnntables(tablename) values( ''?'')'
-- create cursor to load rows count into table
declare tabcursor cursor read_only
for select tablename from #dnntables
declare @Tablename varchar(64)
open tabcursor
fetch next from tabcursor into @TableName
while (@@fetch_status <> -1)
begin
set @sql = 'update #dnntables '
set @sql = @sql + 'set tablerows = (select count(*) from ' + @TableName + ')'
set @sql = @sql + 'where tablename = ''' + @TableName + ''''
--print @sql -- uncomment to see generated update command
exec (@sql) -- note: must enclose in brackets to executed string
fetch next from tabcursor into @TableName
end
-- dump collected data
--Select * from #dnntables
Select * from #dnntables where Tablerows > 0 order by TableRows desc
-- clean up
close tabcursor
deallocate tabcursor
drop table #dnntables
go
The routine aslo uses the sp_MSforeachtable routine.
Hope these help
Paul.