Table_space1

Posted by: cadarsh89

Tagged in: Untagged 

sp_spaceused [humanresources.employee]
sp_msforeachtable' sp_spaceused ''?'''

 

select * from space_used

select * from sys.sysobjects where name like '%space%'


sp_helptext 'sp_spaceused'

declare @name sysname,@cmd nvarchar(max)
set @name = 'humanresources.employee'
set @cmd = 'sp_spaceused '+'['+@name+']'
select @cmd
exec sp_executesql @cmd

select * from sys.sysobjects where xtype = 'U'


create table tes2(id int)

declare @name nvarchar(max)
declare c1 cursor  read_only for select name from sys.sysobjects where xtype = 'U'

open c1
fetch next from c1 into @name
while @@fetch_status=0
begin

declare @cmd nvarchar(max)
set @cmd = 'sp_spaceused '+'['+@name+']'
exec sp_executesql @cmd
fetch next from c1 into @name
end

close c1
deallocate c1

 

select * from sys.schemas

select * from sys.tables

select a.name,b.name from sys.schemas a, sys.tables b
where a.schema_id = b.schema_id