Search
 
SCRIPT & CODE EXAMPLE
 

SQL

script to run SP_SPACESED on all tables in DB

select 'Database Name: ', db_name()
set nocount on
if exists(select name from tempdb..sysobjects where name='##tmp')
drop table ##tmp
create table ##tmp(nam varchar(50), rows int, res varchar(15),data varchar(15),ind_sze varchar(15),unsed varchar(15))
go
declare @tblname varchar(50)
declare tblname CURSOR for select name from sysobjects where xtype='U'
open tblname
Fetch next from tblname into @tblname
WHILE @@FETCH_STATUS = 0
BEGIN
insert into ##tmp
exec sp_spaceused @tblname
  FETCH NEXT FROM tblname INTO @tblname
END
CLOSE tblname
deallocate tblname
go
select nam Table_Name,rows Total_Rows,res Total_Table_Size,data Data_size,ind_sze Index_Size,unsed Unused_Space from ##tmp
order by Total_Rows
drop table ##tmp
Comment

PREVIOUS NEXT
Code Example
Sql :: spfile oracle 
Sql :: influxdb clone measurement 
Sql :: sql convert to linq online 
Sql :: postgresql between month 
Sql :: exel bulk insert 
Sql :: disadvantages of stored procedures sql 
Sql :: value of sold product using having and group by in sql 
Sql :: sql eomonth(getdate) 
Sql :: root mysqu 
Sql :: One table with another 
Sql :: Is there a way to use read_sql_query and the query has WHERE column = Variable? 
Sql :: how to get employee having maximum experience in mysql 
Sql :: pl sql join 3 tables 
Sql :: if new such record in where condition in sql so what is return 
Sql :: CREATE MULTIPLE FK 
Sql :: TSQL Code Snippet For Optimized Sales Query 
Sql :: SQL Hello, [firstname] [lastname] 
Sql :: debian 10 install postgresql 2ndquadrant 
Sql :: 165001709 
Sql :: phpmyadmin mysql conflict 
Sql :: oracle list subpartitions 
Sql :: add id column to temp table insert 
Sql :: valadate mysql 
Sql :: stratified sampling sql 
Sql :: fonction stockée pl/sql 
Sql :: grouping function in mysql 
Sql :: plsql to generate all combinations of specified number of characters in string 
Sql :: mysql beautify output 
Sql :: group by join columns per table 
Sql :: how to connect pgadmin with excel 
ADD CONTENT
Topic
Content
Source link
Name
5+2 =